summaryrefslogtreecommitdiffstats
path: root/src/Generating/HeiGen.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-11-13 21:28:50 +0100
committerMattes D <github@xoft.cz>2014-11-13 21:28:50 +0100
commit7a3b3aeb3c28b7ba899d6dff2b5e160a95529f40 (patch)
treeffb4c4568b3a0d17ace705d1f8e8683935c80511 /src/Generating/HeiGen.cpp
parentGenerator: Shape initial refactoring. (diff)
downloadcuberite-7a3b3aeb3c28b7ba899d6dff2b5e160a95529f40.tar
cuberite-7a3b3aeb3c28b7ba899d6dff2b5e160a95529f40.tar.gz
cuberite-7a3b3aeb3c28b7ba899d6dff2b5e160a95529f40.tar.bz2
cuberite-7a3b3aeb3c28b7ba899d6dff2b5e160a95529f40.tar.lz
cuberite-7a3b3aeb3c28b7ba899d6dff2b5e160a95529f40.tar.xz
cuberite-7a3b3aeb3c28b7ba899d6dff2b5e160a95529f40.tar.zst
cuberite-7a3b3aeb3c28b7ba899d6dff2b5e160a95529f40.zip
Diffstat (limited to '')
-rw-r--r--src/Generating/HeiGen.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp
index 86f934c16..61d087c17 100644
--- a/src/Generating/HeiGen.cpp
+++ b/src/Generating/HeiGen.cpp
@@ -150,6 +150,51 @@ bool cHeiGenCache::GetHeightAt(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_Rel
////////////////////////////////////////////////////////////////////////////////
+// cHeiGenMultiCache:
+
+cHeiGenMultiCache::cHeiGenMultiCache(cTerrainHeightGenPtr a_HeiGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches):
+ m_NumSubCaches(a_NumSubCaches)
+{
+ // Create the individual sub-caches:
+ m_SubCaches.reserve(a_NumSubCaches);
+ for (size_t i = 0; i < a_NumSubCaches; i++)
+ {
+ m_SubCaches.push_back(std::make_shared<cHeiGenCache>(a_HeiGenToCache, a_SubCacheSize));
+ }
+}
+
+
+
+
+
+void cHeiGenMultiCache::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
+{
+ // Get the subcache responsible for this chunk:
+ const size_t cacheIdx = ((size_t)a_ChunkX + m_CoeffZ * (size_t)a_ChunkZ) % m_NumSubCaches;
+
+ // Ask the subcache:
+ m_SubCaches[cacheIdx]->GenHeightMap(a_ChunkX, a_ChunkZ, a_HeightMap);
+}
+
+
+
+
+
+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:
+ const size_t cacheIdx = ((size_t)a_ChunkX + m_CoeffZ * (size_t)a_ChunkZ) % m_NumSubCaches;
+
+ // Ask the subcache:
+ return m_SubCaches[cacheIdx]->GetHeightAt(a_ChunkX, a_ChunkZ, a_RelX, a_RelZ, a_Height);
+}
+
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// cHeiGenClassic:
cHeiGenClassic::cHeiGenClassic(int a_Seed) :