From b8fbba5eb92cda32b13d65f3704adf778da82f38 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 11 Nov 2015 10:32:42 +0100 Subject: Added PieceStructures generator. --- src/Generating/HeiGen.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/Generating/HeiGen.cpp') 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: -- cgit v1.2.3