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 09:59:59 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-06 09:59:59 +0200
commit27d0e01160e3ec04460c20eb9e0682a1bb88e270 (patch)
tree80e81abb39449ea4ddc85cae2e5f85bf44a297af /source/Generating/DistortedHeightmap.cpp
parentRe-worked generator subobject ownership, added a cache for the CompositionGen (diff)
downloadcuberite-27d0e01160e3ec04460c20eb9e0682a1bb88e270.tar
cuberite-27d0e01160e3ec04460c20eb9e0682a1bb88e270.tar.gz
cuberite-27d0e01160e3ec04460c20eb9e0682a1bb88e270.tar.bz2
cuberite-27d0e01160e3ec04460c20eb9e0682a1bb88e270.tar.lz
cuberite-27d0e01160e3ec04460c20eb9e0682a1bb88e270.tar.xz
cuberite-27d0e01160e3ec04460c20eb9e0682a1bb88e270.tar.zst
cuberite-27d0e01160e3ec04460c20eb9e0682a1bb88e270.zip
Diffstat (limited to '')
-rw-r--r--source/Generating/DistortedHeightmap.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/Generating/DistortedHeightmap.cpp b/source/Generating/DistortedHeightmap.cpp
index b495aab22..275acb4ab 100644
--- a/source/Generating/DistortedHeightmap.cpp
+++ b/source/Generating/DistortedHeightmap.cpp
@@ -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);