summaryrefslogtreecommitdiffstats
path: root/source/Generating/CompoGen.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-05 21:56:45 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-05 21:56:45 +0200
commite88cdf8da714473624b221aca5a6feed2154a885 (patch)
treed5c49f766776e7e63d13dcca39fedbeda1db90db /source/Generating/CompoGen.h
parentFixed Biomal CompoGen to set heightmap correctly when underwater (diff)
downloadcuberite-e88cdf8da714473624b221aca5a6feed2154a885.tar
cuberite-e88cdf8da714473624b221aca5a6feed2154a885.tar.gz
cuberite-e88cdf8da714473624b221aca5a6feed2154a885.tar.bz2
cuberite-e88cdf8da714473624b221aca5a6feed2154a885.tar.lz
cuberite-e88cdf8da714473624b221aca5a6feed2154a885.tar.xz
cuberite-e88cdf8da714473624b221aca5a6feed2154a885.tar.zst
cuberite-e88cdf8da714473624b221aca5a6feed2154a885.zip
Diffstat (limited to '')
-rw-r--r--source/Generating/CompoGen.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/source/Generating/CompoGen.h b/source/Generating/CompoGen.h
index 57233e2fd..8391de66e 100644
--- a/source/Generating/CompoGen.h
+++ b/source/Generating/CompoGen.h
@@ -6,6 +6,8 @@
- cCompoGenDebugBiomes
- cCompoGenClassic
- cCompoGenBiomal
+ - cCompoGenNether
+ - cCompoGenCache
*/
@@ -139,3 +141,41 @@ protected:
+
+/// Caches most-recently-used chunk composition of another composition generator. Caches only the types and metas
+class cCompoGenCache :
+ public cTerrainCompositionGen
+{
+public:
+ cCompoGenCache(cTerrainCompositionGen * a_Underlying, int a_CacheSize); // Doesn't take ownership of a_Underlying
+ ~cCompoGenCache();
+
+ // cTerrainCompositionGen override:
+ virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override;
+
+protected:
+
+ cTerrainCompositionGen * m_Underlying;
+
+ struct sCacheData
+ {
+ int m_ChunkX;
+ int m_ChunkZ;
+ cChunkDef::BlockTypes m_BlockTypes;
+ cChunkDesc::BlockNibbleBytes m_BlockMetas; // The metas are uncompressed, 1 meta per byte
+ } ;
+
+ // 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)
+} ;
+
+
+
+