diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-03-08 17:39:43 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2021-03-18 00:44:42 +0100 |
commit | 5ca3a7c2e76bc91356aaa1c6bc3d12bb2a3c6e9c (patch) | |
tree | ea5f79ad71456dcbf4f658a61cc259ac4e6e7d79 /src/Generating/HeiGen.h | |
parent | Add heraldry names to banner pattern API docs (diff) | |
download | cuberite-5ca3a7c2e76bc91356aaa1c6bc3d12bb2a3c6e9c.tar cuberite-5ca3a7c2e76bc91356aaa1c6bc3d12bb2a3c6e9c.tar.gz cuberite-5ca3a7c2e76bc91356aaa1c6bc3d12bb2a3c6e9c.tar.bz2 cuberite-5ca3a7c2e76bc91356aaa1c6bc3d12bb2a3c6e9c.tar.lz cuberite-5ca3a7c2e76bc91356aaa1c6bc3d12bb2a3c6e9c.tar.xz cuberite-5ca3a7c2e76bc91356aaa1c6bc3d12bb2a3c6e9c.tar.zst cuberite-5ca3a7c2e76bc91356aaa1c6bc3d12bb2a3c6e9c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Generating/HeiGen.h | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/Generating/HeiGen.h b/src/Generating/HeiGen.h index ebdfef70f..6f2101043 100644 --- a/src/Generating/HeiGen.h +++ b/src/Generating/HeiGen.h @@ -28,8 +28,7 @@ class cHeiGenCache : public cTerrainHeightGen { public: - cHeiGenCache(cTerrainHeightGenPtr a_HeiGenToCache, size_t a_CacheSize); - virtual ~cHeiGenCache() override = default; + cHeiGenCache(cTerrainHeightGen & a_HeiGenToCache, size_t a_CacheSize); // cTerrainHeightGen overrides: virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap & a_HeightMap) override; @@ -51,7 +50,7 @@ protected: } ; /** The terrain height generator that is being cached. */ - cTerrainHeightGenPtr m_HeiGenToCache; + cTerrainHeightGen & m_HeiGenToCache; // To avoid moving large amounts of data for the MRU behavior, we MRU-ize indices to an array of the actual data size_t m_CacheSize; @@ -73,7 +72,7 @@ class cHeiGenMultiCache: public cTerrainHeightGen { public: - cHeiGenMultiCache(const cTerrainHeightGenPtr & a_HeightGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches); + cHeiGenMultiCache(std::unique_ptr<cTerrainHeightGen> a_HeightGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches); // cTerrainHeightGen overrides: virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap & a_HeightMap) override; @@ -83,9 +82,6 @@ public: bool GetHeightAt(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelZ, HEIGHTTYPE & a_Height); protected: - typedef std::shared_ptr<cHeiGenCache> cHeiGenCachePtr; - typedef std::vector<cHeiGenCachePtr> cHeiGenCachePtrs; - /** The coefficient used to turn Z coords into index (x + Coeff * z). */ static const size_t m_CoeffZ = 5; @@ -94,7 +90,10 @@ protected: size_t m_NumSubCaches; /** The individual sub-caches. */ - cHeiGenCachePtrs m_SubCaches; + std::vector<std::unique_ptr<cHeiGenCache>> m_SubCaches; + + /** The underlying height generator. */ + std::unique_ptr<cTerrainHeightGen> m_Underlying; }; @@ -174,9 +173,9 @@ class cHeiGenBiomal: public: - cHeiGenBiomal(int a_Seed, cBiomeGenPtr a_BiomeGen): + cHeiGenBiomal(int a_Seed, cBiomeGen & a_BiomeGen): m_Noise(a_Seed), - m_BiomeGen(std::move(a_BiomeGen)) + m_BiomeGen(a_BiomeGen) { } @@ -192,8 +191,8 @@ protected: typedef cChunkDef::BiomeMap BiomeNeighbors[3][3]; - cNoise m_Noise; - cBiomeGenPtr m_BiomeGen; + cNoise m_Noise; + cBiomeGen & m_BiomeGen; // Per-biome terrain generator parameters: struct sGenParam @@ -208,7 +207,3 @@ protected: NOISE_DATATYPE GetHeightAt(int a_RelX, int a_RelZ, int a_ChunkX, int a_ChunkZ, const BiomeNeighbors & a_BiomeNeighbors); } ; - - - - |