diff options
Diffstat (limited to 'src/Generating/HeiGen.cpp')
-rw-r--r-- | src/Generating/HeiGen.cpp | 42 |
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: |