Probably fixes #2021. Optimization for foam generation while I'm at it (it's faster now, but there's a new temporary array of the size of the map)
This was SVN commit r13555.
This commit is contained in:
parent
071c976693
commit
408c30e061
@ -269,10 +269,18 @@ void WaterManager::CreateSuperfancyInfo(CSimulation2* simulation)
|
|||||||
u8* waveForceHQ = new u8[mapSize*mapSize];
|
u8* waveForceHQ = new u8[mapSize*mapSize];
|
||||||
u16 waterHeightInu16 = m_WaterHeight/HEIGHT_SCALE;
|
u16 waterHeightInu16 = m_WaterHeight/HEIGHT_SCALE;
|
||||||
|
|
||||||
|
// used to cache terrain normals since otherwise we'd recalculate them a lot (I'm blurring the "normal" map).
|
||||||
|
// this might be updated to actually cache in the terrain manager but that's not for now.
|
||||||
|
CVector3D* normals = new CVector3D[mapSize*mapSize];
|
||||||
|
|
||||||
|
// calculate wave force (not really used right now)
|
||||||
|
// and puts into "normals" the terrain normal at that point
|
||||||
|
// so as to avoid recalculating terrain normals too often.
|
||||||
for (ssize_t i = 0; i < mapSize; ++i)
|
for (ssize_t i = 0; i < mapSize; ++i)
|
||||||
{
|
{
|
||||||
for (ssize_t j = 0; j < mapSize; ++j)
|
for (ssize_t j = 0; j < mapSize; ++j)
|
||||||
{
|
{
|
||||||
|
normals[j*mapSize + i] = terrain->CalcExactNormal(((float)i)*4.0f,((float)j)*4.0f);
|
||||||
if (circular && (i-halfSize)*(i-halfSize)+(j-halfSize)*(j-halfSize) > mSize)
|
if (circular && (i-halfSize)*(i-halfSize)+(j-halfSize)*(j-halfSize) > mSize)
|
||||||
{
|
{
|
||||||
waveForceHQ[j*mapSize + i] = 255;
|
waveForceHQ[j*mapSize + i] = 255;
|
||||||
@ -370,7 +378,7 @@ void WaterManager::CreateSuperfancyInfo(CSimulation2* simulation)
|
|||||||
{
|
{
|
||||||
for (int yy = -4; yy <= 4; yy += 2)
|
for (int yy = -4; yy <= 4; yy += 2)
|
||||||
{
|
{
|
||||||
normal += terrain->CalcExactNormal(((float)i+xx)*4.0f,((float)j+yy)*4.0f);
|
normal += normals[(j+yy)*mapSize + (i+xx)];
|
||||||
if (terrain->GetVertexGroundLevel(i+xx,j+yy) < heightmap[j*mapSize + i]*HEIGHT_SCALE)
|
if (terrain->GetVertexGroundLevel(i+xx,j+yy) < heightmap[j*mapSize + i]*HEIGHT_SCALE)
|
||||||
waterRaise += heightmap[j*mapSize + i]*HEIGHT_SCALE - terrain->GetVertexGroundLevel(i+xx,j+yy);
|
waterRaise += heightmap[j*mapSize + i]*HEIGHT_SCALE - terrain->GetVertexGroundLevel(i+xx,j+yy);
|
||||||
}
|
}
|
||||||
@ -397,6 +405,7 @@ void WaterManager::CreateSuperfancyInfo(CSimulation2* simulation)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete[] normals;
|
||||||
delete[] waveForceHQ;
|
delete[] waveForceHQ;
|
||||||
|
|
||||||
// TODO: The rest should be cleaned up
|
// TODO: The rest should be cleaned up
|
||||||
@ -538,7 +547,6 @@ void WaterManager::CreateSuperfancyInfo(CSimulation2* simulation)
|
|||||||
waves_vertex_data.push_back(vertex[2]);
|
waves_vertex_data.push_back(vertex[2]);
|
||||||
waves_indices.push_back(waves_vertex_data.size());
|
waves_indices.push_back(waves_vertex_data.size());
|
||||||
waves_vertex_data.push_back(vertex[3]);
|
waves_vertex_data.push_back(vertex[3]);
|
||||||
}
|
|
||||||
|
|
||||||
// waves
|
// waves
|
||||||
// allocate vertex buffer
|
// allocate vertex buffer
|
||||||
@ -548,6 +556,8 @@ void WaterManager::CreateSuperfancyInfo(CSimulation2* simulation)
|
|||||||
// Construct indices buffer
|
// Construct indices buffer
|
||||||
m_VBWavesIndices = g_VBMan.Allocate(sizeof(GLushort), waves_indices.size(), GL_STATIC_DRAW, GL_ELEMENT_ARRAY_BUFFER);
|
m_VBWavesIndices = g_VBMan.Allocate(sizeof(GLushort), waves_indices.size(), GL_STATIC_DRAW, GL_ELEMENT_ARRAY_BUFFER);
|
||||||
m_VBWavesIndices->m_Owner->UpdateChunkVertices(m_VBWavesIndices, &waves_indices[0]);
|
m_VBWavesIndices->m_Owner->UpdateChunkVertices(m_VBWavesIndices, &waves_indices[0]);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user