diff options
author | Mattes D <github@xoft.cz> | 2019-09-07 23:02:05 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2019-09-08 20:21:49 +0200 |
commit | e4ac84a6ab6354d1b5ff1af90ae896e3704429e7 (patch) | |
tree | 492f1667114eb95f75095512876c46c5907ed2b9 /src/Generating/BioGen.h | |
parent | Generator: Added repeatability test. (diff) | |
download | cuberite-e4ac84a6ab6354d1b5ff1af90ae896e3704429e7.tar cuberite-e4ac84a6ab6354d1b5ff1af90ae896e3704429e7.tar.gz cuberite-e4ac84a6ab6354d1b5ff1af90ae896e3704429e7.tar.bz2 cuberite-e4ac84a6ab6354d1b5ff1af90ae896e3704429e7.tar.lz cuberite-e4ac84a6ab6354d1b5ff1af90ae896e3704429e7.tar.xz cuberite-e4ac84a6ab6354d1b5ff1af90ae896e3704429e7.tar.zst cuberite-e4ac84a6ab6354d1b5ff1af90ae896e3704429e7.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Generating/BioGen.h | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/Generating/BioGen.h b/src/Generating/BioGen.h index 104916761..c20babde0 100644 --- a/src/Generating/BioGen.h +++ b/src/Generating/BioGen.h @@ -33,7 +33,7 @@ protected: EMCSBiome m_Biome; // cBiomeGen overrides: - virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; + virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) override; virtual void InitializeBiomeGen(cIniFile & a_IniFile) override; } ; @@ -48,8 +48,10 @@ class cBioGenCache : typedef cBiomeGen super; public: + cBioGenCache(cBiomeGenPtr a_BioGenToCache, size_t a_CacheSize); - virtual ~cBioGenCache() override; + virtual ~cBioGenCache() override = default; + protected: @@ -57,22 +59,27 @@ protected: struct sCacheData { - int m_ChunkX; - int m_ChunkZ; + cChunkCoords m_Coords; cChunkDef::BiomeMap m_BiomeMap; + + /** Default constructor: Fill in bogus coords so that the item is not used in the cache until properly calculated. */ + sCacheData(): + m_Coords(0x7fffffff, 0x7fffffff) + { + } } ; // 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; - size_t * m_CacheOrder; // MRU-ized order, indices into m_CacheData array - sCacheData * m_CacheData; // m_CacheData[m_CacheOrder[0]] is the most recently used + size_t m_CacheSize; + std::vector<size_t> m_CacheOrder; // MRU-ized order, indices into m_CacheData array + std::vector<sCacheData> m_CacheData; // m_CacheData[m_CacheOrder[0]] is the most recently used // Cache statistics size_t m_NumHits; size_t m_NumMisses; size_t m_TotalChain; // Number of cache items walked to get to a hit (only added for hits) - virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; + virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) override; virtual void InitializeBiomeGen(cIniFile & a_IniFile) override; } ; @@ -104,7 +111,7 @@ protected: cBiomeGenPtrs m_Caches; - virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; + virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) override; virtual void InitializeBiomeGen(cIniFile & a_IniFile) override; }; @@ -141,7 +148,7 @@ protected: int m_BiomeSize; // cBiomeGen overrides: - virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; + virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) override; virtual void InitializeBiomeGen(cIniFile & a_IniFile) override; } ; @@ -164,7 +171,7 @@ protected: cVoronoiMap m_Voronoi; // cBiomeGen overrides: - virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; + virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) override; virtual void InitializeBiomeGen(cIniFile & a_IniFile) override; EMCSBiome VoronoiBiome(int a_BlockX, int a_BlockZ); @@ -198,7 +205,7 @@ protected: int m_CellSize; // cBiomeGen overrides: - virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; + virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) override; virtual void InitializeBiomeGen(cIniFile & a_IniFile) override; /** Distorts the coords using a Perlin-like noise */ @@ -237,26 +244,26 @@ protected: typedef double DblMap[17 * 17]; // x + 17 * z, expected trimmed into [0..1] range // cBiomeGen overrides: - virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; + virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) override; virtual void InitializeBiomeGen(cIniFile & a_IniFile) override; /** Step 1: Decides between ocean, land and mushroom, using a DistVoronoi with special conditions and post-processing for mushroom islands Sets biomes to biOcean, -1 (i.e. land), biMushroomIsland or biMushroomShore. */ - void DecideOceanLandMushroom(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap); + void DecideOceanLandMushroom(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap); /** Step 2: Add rivers to the land Flips some "-1" biomes into biRiver. */ - void AddRivers(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap); + void AddRivers(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap); /** Step 3: Decide land biomes using a temperature / humidity map; freeze ocean / river in low temperatures. Flips all remaining "-1" biomes into land biomes. Also flips some biOcean and biRiver into biFrozenOcean, biFrozenRiver, based on temp map. */ - void ApplyTemperatureHumidity(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap); + void ApplyTemperatureHumidity(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap); /** Distorts the coords using a Perlin-like noise, with a specified cell-size */ void Distort(int a_BlockX, int a_BlockZ, int & a_DistortedX, int & a_DistortedZ, int a_CellSize); /** Builds two Perlin-noise maps, one for temperature, the other for humidity. Trims both into [0..255] range */ - void BuildTemperatureHumidityMaps(int a_ChunkX, int a_ChunkZ, IntMap & a_TemperatureMap, IntMap & a_HumidityMap); + void BuildTemperatureHumidityMaps(cChunkCoords a_ChunkCoords, IntMap & a_TemperatureMap, IntMap & a_HumidityMap); /** Flips all remaining "-1" biomes into land biomes using the two maps */ void DecideLandBiomes(cChunkDef::BiomeMap & a_BiomeMap, const IntMap & a_TemperatureMap, const IntMap & a_HumidityMap); @@ -302,7 +309,7 @@ protected: // cBiomeGen overrides: - virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; + virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) override; virtual void InitializeBiomeGen(cIniFile & a_IniFile) override; /** Selects biome from the specified biome group, based on the specified index. |