1
0

DistortedHeightmap: Small optimizations, memory leak fix.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1449 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2013-05-06 12:20:25 +00:00
parent 27d0e01160
commit 7004622e8b
4 changed files with 34 additions and 2 deletions

View File

@@ -55,7 +55,8 @@ cDistortedHeightmap::cDistortedHeightmap(int a_Seed, cBiomeGen & a_BiomeGen) :
m_NoiseArrayX(m_NoiseArray),
m_NoiseArrayZ(m_NoiseArray + 17 * 17 * 32),
m_BiomeGen(a_BiomeGen),
m_HeightGen(new cHeiGenBiomal(a_Seed, a_BiomeGen), 64)
m_UnderlyingHeiGen(a_Seed, a_BiomeGen),
m_HeightGen(&m_UnderlyingHeiGen, 64)
{
}
@@ -243,6 +244,16 @@ int cDistortedHeightmap::GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z)
{
return cChunkDef::GetHeight(m_CurChunkHeights, RelX, RelZ);
}
// Ask the cache:
HEIGHTTYPE res = 0;
if (m_HeightGen.GetHeightAt(ChunkX, ChunkZ, RelX, RelZ, res))
{
// The height was in the cache
return res;
}
// The height is not in the cache, generate full heightmap and get it there:
cChunkDef::HeightMap Heightmap;
m_HeightGen.GenHeightMap(ChunkX, ChunkZ, Heightmap);
return cChunkDef::GetHeight(Heightmap, RelX, RelZ);