1
0

DistortedHeightmap: Slight speed increase

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1448 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2013-05-06 07:59:59 +00:00
parent e88cdf8da7
commit 27d0e01160
2 changed files with 11 additions and 0 deletions

View File

@@ -85,6 +85,7 @@ void cDistortedHeightmap::PrepareState(int a_ChunkX, int a_ChunkZ)
m_CurChunkX = a_ChunkX;
m_CurChunkZ = a_ChunkZ;
m_HeightGen.GenHeightMap(a_ChunkX, a_ChunkZ, m_CurChunkHeights);
GenerateNoiseArray(m_NoiseArrayX, m_Noise1, m_Noise2, m_Noise3);
UpdateDistortAmps();
}
@@ -236,6 +237,12 @@ int cDistortedHeightmap::GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z)
int ChunkZ = (int)floor(a_Z / (NOISE_DATATYPE)16);
int RelX = (int)(a_X - (NOISE_DATATYPE)ChunkX * cChunkDef::Width);
int RelZ = (int)(a_Z - (NOISE_DATATYPE)ChunkZ * cChunkDef::Width);
// If we're withing the same chunk, return the pre-cached heightmap:
if ((ChunkX == m_CurChunkX) && (ChunkZ == m_CurChunkZ))
{
return cChunkDef::GetHeight(m_CurChunkHeights, RelX, RelZ);
}
cChunkDef::HeightMap Heightmap;
m_HeightGen.GenHeightMap(ChunkX, ChunkZ, Heightmap);
return cChunkDef::GetHeight(Heightmap, RelX, RelZ);