Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
cHeiGenMultiCache Class Reference

Caches heightmaps in multiple underlying caches to improve the distribution and lower the chain length. More...

#include <HeiGen.h>

Inheritance diagram for cHeiGenMultiCache:
Inheritance graph
[legend]
Collaboration diagram for cHeiGenMultiCache:
Collaboration graph
[legend]

Public Member Functions

 cHeiGenMultiCache (std::unique_ptr< cTerrainHeightGen > a_HeightGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches)
 
virtual void GenHeightMap (cChunkCoords a_ChunkCoords, cChunkDef::HeightMap &a_HeightMap) override
 Retrieves the heightmap for the specified chunk. More...
 
virtual HEIGHTTYPE GetHeightAt (int a_BlockX, int a_BlockZ) override
 Returns the height at the specified column. More...
 
bool GetHeightAt (int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelZ, HEIGHTTYPE &a_Height)
 Retrieves height at the specified point in the cache, returns true if found, false if not found. More...
 
- Public Member Functions inherited from cTerrainHeightGen
virtual void InitializeHeightGen (cIniFile &a_IniFile)
 Initializes the generator, reading its parameters from the INI file. More...
 
virtual ~cTerrainHeightGen ()
 

Protected Attributes

size_t m_NumSubCaches
 Number of sub-caches, pulled out of m_SubCaches.size() for performance reasons. More...
 
std::vector< std::unique_ptr< cHeiGenCache > > m_SubCaches
 The individual sub-caches. More...
 
std::unique_ptr< cTerrainHeightGenm_Underlying
 The underlying height generator. More...
 

Static Protected Attributes

static const size_t m_CoeffZ = 5
 The coefficient used to turn Z coords into index (x + Coeff * z). More...
 

Additional Inherited Members

- Static Public Member Functions inherited from cTerrainHeightGen
static std::unique_ptr< cTerrainHeightGenCreateHeightGen (cIniFile &a_IniFile, cBiomeGen &a_BiomeGen, int a_Seed, bool &a_CacheOffByDefault)
 Creates a cTerrainHeightGen descendant based on the INI file settings. More...
 

Detailed Description

Caches heightmaps in multiple underlying caches to improve the distribution and lower the chain length.

Definition at line 71 of file HeiGen.h.

Constructor & Destructor Documentation

◆ cHeiGenMultiCache()

cHeiGenMultiCache::cHeiGenMultiCache ( std::unique_ptr< cTerrainHeightGen a_HeightGenToCache,
size_t  a_SubCacheSize,
size_t  a_NumSubCaches 
)

Definition at line 222 of file HeiGen.cpp.

Member Function Documentation

◆ GenHeightMap()

void cHeiGenMultiCache::GenHeightMap ( cChunkCoords  a_ChunkCoords,
cChunkDef::HeightMap a_HeightMap 
)
overridevirtual

Retrieves the heightmap for the specified chunk.

Implements cTerrainHeightGen.

Definition at line 238 of file HeiGen.cpp.

◆ GetHeightAt() [1/2]

HEIGHTTYPE cHeiGenMultiCache::GetHeightAt ( int  a_BlockX,
int  a_BlockZ 
)
overridevirtual

Returns the height at the specified column.

The default implementation calls GenHeightMap(), and then queries the heightmap. Descendants may provide a better-performing method.

Reimplemented from cTerrainHeightGen.

Definition at line 251 of file HeiGen.cpp.

◆ GetHeightAt() [2/2]

bool cHeiGenMultiCache::GetHeightAt ( int  a_ChunkX,
int  a_ChunkZ,
int  a_RelX,
int  a_RelZ,
HEIGHTTYPE a_Height 
)

Retrieves height at the specified point in the cache, returns true if found, false if not found.

Definition at line 272 of file HeiGen.cpp.

Member Data Documentation

◆ m_CoeffZ

const size_t cHeiGenMultiCache::m_CoeffZ = 5
staticprotected

The coefficient used to turn Z coords into index (x + Coeff * z).

Definition at line 87 of file HeiGen.h.

◆ m_NumSubCaches

size_t cHeiGenMultiCache::m_NumSubCaches
protected

Number of sub-caches, pulled out of m_SubCaches.size() for performance reasons.

Definition at line 90 of file HeiGen.h.

◆ m_SubCaches

std::vector<std::unique_ptr<cHeiGenCache> > cHeiGenMultiCache::m_SubCaches
protected

The individual sub-caches.

Definition at line 93 of file HeiGen.h.

◆ m_Underlying

std::unique_ptr<cTerrainHeightGen> cHeiGenMultiCache::m_Underlying
protected

The underlying height generator.

Definition at line 96 of file HeiGen.h.


The documentation for this class was generated from the following files: