summaryrefslogtreecommitdiffstats
path: root/source/Generating/DistortedHeightmap.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-06 14:20:25 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-06 14:20:25 +0200
commit7004622e8b99c56ef4cc8c528fbe510b36d604ed (patch)
tree12abd33e558e18db32dddbc2d20b9087bd418e3f /source/Generating/DistortedHeightmap.cpp
parentDistortedHeightmap: Slight speed increase (diff)
downloadcuberite-7004622e8b99c56ef4cc8c528fbe510b36d604ed.tar
cuberite-7004622e8b99c56ef4cc8c528fbe510b36d604ed.tar.gz
cuberite-7004622e8b99c56ef4cc8c528fbe510b36d604ed.tar.bz2
cuberite-7004622e8b99c56ef4cc8c528fbe510b36d604ed.tar.lz
cuberite-7004622e8b99c56ef4cc8c528fbe510b36d604ed.tar.xz
cuberite-7004622e8b99c56ef4cc8c528fbe510b36d604ed.tar.zst
cuberite-7004622e8b99c56ef4cc8c528fbe510b36d604ed.zip
Diffstat (limited to 'source/Generating/DistortedHeightmap.cpp')
-rw-r--r--source/Generating/DistortedHeightmap.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/source/Generating/DistortedHeightmap.cpp b/source/Generating/DistortedHeightmap.cpp
index 275acb4ab..a8441525b 100644
--- a/source/Generating/DistortedHeightmap.cpp
+++ b/source/Generating/DistortedHeightmap.cpp
@@ -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);