Fixes incorrect reuse of a member variable in WaterManager, caused a crash when starting a new map in Atlas after loading a water map. Fixes #2784.
Fixes likely mem leaks from not cleaning up vertex buffer allocations This was SVN commit r15715.
This commit is contained in:
parent
e027981f95
commit
41b98a6f12
@ -107,6 +107,8 @@ WaterManager::WaterManager()
|
||||
m_DistanceHeightmap = NULL;
|
||||
m_BlurredNormalMap = NULL;
|
||||
m_WindStrength = NULL;
|
||||
|
||||
m_ShoreWaves_VBIndices = NULL;
|
||||
|
||||
m_WaterUgly = false;
|
||||
m_WaterFancyEffects = false;
|
||||
@ -141,7 +143,15 @@ WaterManager::~WaterManager()
|
||||
|
||||
// TODO: when c++11 is around, use lambdas or something because short Korea is best Korea.
|
||||
for (size_t i = 0; i < m_ShoreWaves.size(); ++i)
|
||||
delete m_ShoreWaves[i];
|
||||
{
|
||||
WaveObject* obj = m_ShoreWaves[i];
|
||||
if (obj->m_VBvertices)
|
||||
g_VBMan.Release(obj->m_VBvertices);
|
||||
delete obj;
|
||||
}
|
||||
|
||||
if (m_ShoreWaves_VBIndices)
|
||||
g_VBMan.Release(m_ShoreWaves_VBIndices);
|
||||
|
||||
SAFE_ARRAY_DELETE(m_DistanceHeightmap);
|
||||
SAFE_ARRAY_DELETE(m_BlurredNormalMap);
|
||||
@ -439,9 +449,17 @@ void WaterManager::CreateWaveMeshes()
|
||||
|
||||
// TODO: when c++11 is around, use lambdas or something because short Korea is best Korea.
|
||||
for (size_t i = 0; i < m_ShoreWaves.size(); ++i)
|
||||
delete m_ShoreWaves[i];
|
||||
{
|
||||
WaveObject* obj = m_ShoreWaves[i];
|
||||
if (obj->m_VBvertices)
|
||||
g_VBMan.Release(obj->m_VBvertices);
|
||||
delete obj;
|
||||
}
|
||||
m_ShoreWaves.clear();
|
||||
|
||||
if (m_ShoreWaves_VBIndices)
|
||||
g_VBMan.Release(m_ShoreWaves_VBIndices);
|
||||
|
||||
if (m_Waviness < 5.0f && m_WaterType != L"ocean")
|
||||
return;
|
||||
|
||||
@ -455,6 +473,7 @@ void WaterManager::CreateWaveMeshes()
|
||||
// Second step: create chains out of those coastal points.
|
||||
static const int around[8][2] = { { -1,-1 }, { -1,0 }, { -1,1 }, { 0,1 }, { 1,1 }, { 1,0 }, { 1,-1 }, { 0,-1 } };
|
||||
|
||||
std::vector<std::deque<CoastalPoint> > CoastalPointsChains;
|
||||
while (!CoastalPointsSet.empty())
|
||||
{
|
||||
int index = *(CoastalPointsSet.begin());
|
||||
|
@ -50,8 +50,6 @@ public:
|
||||
float* m_DistanceHeightmap; // How far from the shore a point is. Manhattan
|
||||
CVector3D* m_BlurredNormalMap; // Cache a slightly blurred map of the normals of the terrain.
|
||||
|
||||
std::vector<std::deque<CoastalPoint> > CoastalPointsChains;
|
||||
|
||||
// Waves vertex buffers
|
||||
std::vector< WaveObject* > m_ShoreWaves; // TODO: once we get C++11, remove pointer
|
||||
// Waves indices buffer. Only one since All Wave Objects have the same.
|
||||
|
Loading…
Reference in New Issue
Block a user