diff options
author | sfan5 <sfan5@live.de> | 2021-03-23 15:43:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-23 15:43:26 +0100 |
commit | 2da1eee394554879bf1cee6bc0f7b77acf0b6c43 (patch) | |
tree | c27bf698c21f13263fa3d56cd51ebaeace30ce2e /src/mapgen/mg_biome.h | |
parent | c9eba8440d3dc293a8aa6ffafc045737732da1e1 (diff) | |
download | minetest-2da1eee394554879bf1cee6bc0f7b77acf0b6c43.tar.gz minetest-2da1eee394554879bf1cee6bc0f7b77acf0b6c43.tar.bz2 minetest-2da1eee394554879bf1cee6bc0f7b77acf0b6c43.zip |
Fix broken `BiomeGen` abstraction (#11107)
Diffstat (limited to 'src/mapgen/mg_biome.h')
-rw-r--r-- | src/mapgen/mg_biome.h | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/mapgen/mg_biome.h b/src/mapgen/mg_biome.h index be4cfea4d..c85afc3a0 100644 --- a/src/mapgen/mg_biome.h +++ b/src/mapgen/mg_biome.h @@ -97,6 +97,15 @@ public: virtual BiomeGenType getType() const = 0; + // Clone this BiomeGen and set a the new BiomeManager to be used by the copy + virtual BiomeGen *clone(BiomeManager *biomemgr) const = 0; + + // Check that the internal chunk size is what the mapgen expects, just to be sure. + inline void assertChunkSize(v3s16 expect) const + { + FATAL_ERROR_IF(m_csize != expect, "Chunk size mismatches"); + } + // Calculates the biome at the exact position provided. This function can // be called at any time, but may be less efficient than the latter methods, // depending on implementation. @@ -158,12 +167,18 @@ struct BiomeParamsOriginal : public BiomeParams { class BiomeGenOriginal : public BiomeGen { public: BiomeGenOriginal(BiomeManager *biomemgr, - BiomeParamsOriginal *params, v3s16 chunksize); + const BiomeParamsOriginal *params, v3s16 chunksize); virtual ~BiomeGenOriginal(); BiomeGenType getType() const { return BIOMEGEN_ORIGINAL; } + BiomeGen *clone(BiomeManager *biomemgr) const; + + // Slower, meant for Script API use + float calcHeatAtPoint(v3s16 pos) const; + float calcHumidityAtPoint(v3s16 pos) const; Biome *calcBiomeAtPoint(v3s16 pos) const; + void calcBiomeNoise(v3s16 pmin); biome_t *getBiomes(s16 *heightmap, v3s16 pmin); @@ -176,7 +191,7 @@ public: float *humidmap; private: - BiomeParamsOriginal *m_params; + const BiomeParamsOriginal *m_params; Noise *noise_heat; Noise *noise_humidity; @@ -229,14 +244,6 @@ public: virtual void clear(); - // For BiomeGen type 'BiomeGenOriginal' - float getHeatAtPosOriginal(v3s16 pos, NoiseParams &np_heat, - NoiseParams &np_heat_blend, u64 seed) const; - float getHumidityAtPosOriginal(v3s16 pos, NoiseParams &np_humidity, - NoiseParams &np_humidity_blend, u64 seed) const; - const Biome *getBiomeFromNoiseOriginal(float heat, float humidity, - v3s16 pos) const; - private: BiomeManager() {}; |