summaryrefslogtreecommitdiffstats
path: root/src/Generating/HeiGen.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-12-03 13:07:23 +0100
committerMattes D <github@xoft.cz>2015-12-03 13:07:23 +0100
commit3fb356648453169758a9f5649f0ed4c5925d911f (patch)
tree57c90ff51aaeac4b1c2e05538a9f486da0a19f28 /src/Generating/HeiGen.cpp
parentMerge pull request #2696 from Gargaj/breeding (diff)
parentChanged Nether defaults to use PieceStructures. (diff)
downloadcuberite-3fb356648453169758a9f5649f0ed4c5925d911f.tar
cuberite-3fb356648453169758a9f5649f0ed4c5925d911f.tar.gz
cuberite-3fb356648453169758a9f5649f0ed4c5925d911f.tar.bz2
cuberite-3fb356648453169758a9f5649f0ed4c5925d911f.tar.lz
cuberite-3fb356648453169758a9f5649f0ed4c5925d911f.tar.xz
cuberite-3fb356648453169758a9f5649f0ed4c5925d911f.tar.zst
cuberite-3fb356648453169758a9f5649f0ed4c5925d911f.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: