From e0cfbc4d8526a1a1d3afa8fc0774358f4f18b7e2 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 19 Oct 2014 14:01:59 +0200 Subject: Generator: Rewritten to use SharedPtrs. --- src/Generating/BioGen.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/Generating/BioGen.h') diff --git a/src/Generating/BioGen.h b/src/Generating/BioGen.h index 22ddfae5c..5fd0844d9 100644 --- a/src/Generating/BioGen.h +++ b/src/Generating/BioGen.h @@ -48,12 +48,12 @@ class cBioGenCache : typedef cBiomeGen super; public: - cBioGenCache(cBiomeGen * a_BioGenToCache, int a_CacheSize); // Doesn't take ownership of a_BioGenToCache - ~cBioGenCache(); + cBioGenCache(cBiomeGenPtr a_BioGenToCache, int a_CacheSize); + virtual ~cBioGenCache(); protected: - cBiomeGen * m_BioGenToCache; + cBiomeGenPtr m_BioGenToCache; struct sCacheData { @@ -87,19 +87,21 @@ class cBioGenMulticache : typedef cBiomeGen super; public: - /* - a_CacheSize defines the size of each singular cache - a_CachesLength defines how many caches are used for the multicache - */ - cBioGenMulticache(cBiomeGen * a_BioGenToCache, size_t a_CacheSize, size_t a_CachesLength); // Doesn't take ownership of a_BioGenToCache - ~cBioGenMulticache(); + /* Creates a new multicache - a cache that divides the caching into several sub-caches based on the chunk coords. + This allows us to use shorter cache depths with faster lookups for more covered area. (#381) + a_SubCacheSize defines the size of each sub-cache + a_NumSubCaches defines how many sub-caches are used for the multicache. */ + cBioGenMulticache(cBiomeGenPtr a_BioGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches); protected: - typedef std::vector cBiomeGens; + typedef std::vector cBiomeGenPtrs; + + /** Number of sub-caches. Pulled out of m_Caches.size() for faster access. */ + size_t m_NumSubCaches; - size_t m_CachesLength; - cBiomeGens m_Caches; + /** Individual sub-caches. */ + cBiomeGenPtrs m_Caches; virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; -- cgit v1.2.3