summaryrefslogtreecommitdiffstats
path: root/src/Generating/HeiGen.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-11-11 10:32:42 +0100
committerMattes D <github@xoft.cz>2015-12-01 10:35:07 +0100
commitb8fbba5eb92cda32b13d65f3704adf778da82f38 (patch)
tree0c6e8f47ae152e5ffade6f0a7457505101764753 /src/Generating/HeiGen.cpp
parentMerge pull request #2696 from Gargaj/breeding (diff)
downloadcuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar
cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.gz
cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.bz2
cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.lz
cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.xz
cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.zst
cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.zip
Diffstat (limited to 'src/Generating/HeiGen.cpp')
-rw-r--r--src/Generating/HeiGen.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp
index 76d0fbae8..2b3f342bb 100644
--- a/src/Generating/HeiGen.cpp
+++ b/src/Generating/HeiGen.cpp
@@ -192,6 +192,27 @@ void cHeiGenCache::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap
+HEIGHTTYPE cHeiGenCache::GetHeightAt(int a_BlockX, int a_BlockZ)
+{
+ // First try if the chunk is already in the cache:
+ int chunkX, chunkZ;
+ cChunkDef::BlockToChunk(a_BlockX, a_BlockZ, chunkX, chunkZ);
+ HEIGHTTYPE res;
+ if (GetHeightAt(chunkX, chunkZ, a_BlockX - chunkX * cChunkDef::Width, a_BlockZ - chunkZ * cChunkDef::Width, res))
+ {
+ return res;
+ }
+
+ // Chunk not in cache, generate the chunk and ask again:
+ cChunkDef::HeightMap heightMap;
+ GenHeightMap(chunkX, chunkZ, heightMap);
+ return cChunkDef::GetHeight(heightMap, a_BlockX - chunkX * cChunkDef::Width, a_BlockZ - chunkZ * cChunkDef::Width);
+}
+
+
+
+
+
bool cHeiGenCache::GetHeightAt(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelZ, HEIGHTTYPE & a_Height)
{
for (size_t i = 0; i < m_CacheSize; i++)
@@ -240,6 +261,27 @@ void cHeiGenMultiCache::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::Heig
+HEIGHTTYPE cHeiGenMultiCache::GetHeightAt(int a_BlockX, int a_BlockZ)
+{
+ // First try if the chunk is already in the cache:
+ int chunkX, chunkZ;
+ cChunkDef::BlockToChunk(a_BlockX, a_BlockZ, chunkX, chunkZ);
+ HEIGHTTYPE res;
+ if (GetHeightAt(chunkX, chunkZ, a_BlockX - chunkX * cChunkDef::Width, a_BlockZ - chunkZ * cChunkDef::Width, res))
+ {
+ return res;
+ }
+
+ // Chunk not in cache, generate the chunk and ask again:
+ cChunkDef::HeightMap heightMap;
+ GenHeightMap(chunkX, chunkZ, heightMap);
+ return cChunkDef::GetHeight(heightMap, a_BlockX - chunkX * cChunkDef::Width, a_BlockZ - chunkZ * cChunkDef::Width);
+}
+
+
+
+
+
bool cHeiGenMultiCache::GetHeightAt(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelZ, HEIGHTTYPE & a_Height)
{
// Get the subcache responsible for this chunk: