diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-02 15:45:57 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-02 15:45:57 +0200 |
commit | 39a59d68061710db886bc00cb571c6feb8cbdc65 (patch) | |
tree | e7161107299ed6d9488edc476f865ccc94b88146 /source/HeiGen.h | |
parent | Added a cBioGenCache object for caching generated biomes (diff) | |
download | cuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.tar cuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.tar.gz cuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.tar.bz2 cuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.tar.lz cuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.tar.xz cuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.tar.zst cuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.zip |
Diffstat (limited to '')
-rw-r--r-- | source/HeiGen.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/source/HeiGen.h b/source/HeiGen.h index 869f1c67a..d3074487f 100644 --- a/source/HeiGen.h +++ b/source/HeiGen.h @@ -39,6 +39,42 @@ protected: +/// A simple cache that stores N most recently generated chunks' heightmaps; N being settable upon creation
+class cHeiGenCache :
+ public cTerrainHeightGen
+{
+public:
+ cHeiGenCache(cTerrainHeightGen * a_HeiGenToCache, int a_CacheSize); // Takes ownership of a_HeiGenToCache
+ ~cHeiGenCache();
+
+protected:
+
+ cTerrainHeightGen * m_HeiGenToCache;
+
+ struct sCacheData
+ {
+ int m_ChunkX;
+ int m_ChunkZ;
+ cChunkDef::HeightMap m_HeightMap;
+ } ;
+
+ // To avoid moving large amounts of data for the MRU behavior, we MRU-ize indices to an array of the actual data
+ int m_CacheSize;
+ int * m_CacheOrder; // MRU-ized order, indices into m_CacheData array
+ sCacheData * m_CacheData; // m_CacheData[m_CacheOrder[0]] is the most recently used
+
+ // Cache statistics
+ int m_NumHits;
+ int m_NumMisses;
+ int m_TotalChain; // Number of cache items walked to get to a hit (only added for hits)
+
+ virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
+} ;
+
+
+
+
+
class cHeiGenClassic :
public cTerrainHeightGen
{
|