diff options
author | Mattes D <github@xoft.cz> | 2019-09-08 15:59:15 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2019-09-08 20:21:49 +0200 |
commit | ad24702b4e0569318c97391cd930c5956d190016 (patch) | |
tree | 48182f7af3185b8a5ef217ac408e0a3756ba8964 /src/Generating | |
parent | ShapeGen, HeiGen: Changed to use cChunkCoords. (diff) | |
download | cuberite-ad24702b4e0569318c97391cd930c5956d190016.tar cuberite-ad24702b4e0569318c97391cd930c5956d190016.tar.gz cuberite-ad24702b4e0569318c97391cd930c5956d190016.tar.bz2 cuberite-ad24702b4e0569318c97391cd930c5956d190016.tar.lz cuberite-ad24702b4e0569318c97391cd930c5956d190016.tar.xz cuberite-ad24702b4e0569318c97391cd930c5956d190016.tar.zst cuberite-ad24702b4e0569318c97391cd930c5956d190016.zip |
Diffstat (limited to 'src/Generating')
-rw-r--r-- | src/Generating/ChunkGenerator.cpp | 2 | ||||
-rw-r--r-- | src/Generating/ChunkGenerator.h | 4 | ||||
-rw-r--r-- | src/Generating/ComposableGenerator.cpp | 6 | ||||
-rw-r--r-- | src/Generating/ComposableGenerator.h | 4 | ||||
-rw-r--r-- | src/Generating/Noise3DGenerator.cpp | 23 | ||||
-rw-r--r-- | src/Generating/Noise3DGenerator.h | 8 |
6 files changed, 21 insertions, 26 deletions
diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp index 7687eea72..b8486e3d6 100644 --- a/src/Generating/ChunkGenerator.cpp +++ b/src/Generating/ChunkGenerator.cpp @@ -71,7 +71,7 @@ EMCSBiome cChunkGenerator::GetBiomeAt(int a_BlockX, int a_BlockZ) int Y = 0; int ChunkX, ChunkZ; cChunkDef::AbsoluteToRelative(a_BlockX, Y, a_BlockZ, ChunkX, ChunkZ); - GenerateBiomes(ChunkX, ChunkZ, Biomes); + GenerateBiomes({ChunkX, ChunkZ}, Biomes); return cChunkDef::GetBiome(Biomes, a_BlockX, a_BlockZ); } diff --git a/src/Generating/ChunkGenerator.h b/src/Generating/ChunkGenerator.h index 703372094..5fe58c65a 100644 --- a/src/Generating/ChunkGenerator.h +++ b/src/Generating/ChunkGenerator.h @@ -27,7 +27,7 @@ public: /** Generates the biomes for the specified chunk. Used by the world loader if biomes failed loading. */ - virtual void GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) = 0; + virtual void GenerateBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) = 0; /** Returns the biome at the specified coords. Used by ChunkMap if an invalid chunk is queried for biome. @@ -36,7 +36,7 @@ public: /** Does the actual chunk generation. Descendants need to override this and generate into a_ChunkDesc. */ - virtual void Generate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc) = 0; + virtual void Generate(cChunkDesc & a_ChunkDesc) = 0; /** Returns the seed that was read from the INI file. */ int GetSeed(void) const { return m_Seed; } diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index f28de931b..f87d63493 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -141,11 +141,11 @@ void cComposableGenerator::Initialize(cIniFile & a_IniFile) -void cComposableGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) +void cComposableGenerator::GenerateBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) { if (m_BiomeGen != nullptr) // Quick fix for generator deinitializing before the world storage finishes loading { - m_BiomeGen->GenBiomes({a_ChunkX, a_ChunkZ}, a_BiomeMap); + m_BiomeGen->GenBiomes(a_ChunkCoords, a_BiomeMap); } } @@ -153,7 +153,7 @@ void cComposableGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef: -void cComposableGenerator::Generate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc) +void cComposableGenerator::Generate(cChunkDesc & a_ChunkDesc) { if (a_ChunkDesc.IsUsingDefaultBiomes()) { diff --git a/src/Generating/ComposableGenerator.h b/src/Generating/ComposableGenerator.h index 59ce25352..9c643847c 100644 --- a/src/Generating/ComposableGenerator.h +++ b/src/Generating/ComposableGenerator.h @@ -210,8 +210,8 @@ public: // cChunkGenerator::cGenerator overrides: virtual void Initialize(cIniFile & a_IniFile) override; - virtual void GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; - virtual void Generate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc) override; + virtual void GenerateBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) override; + virtual void Generate(cChunkDesc & a_ChunkDesc) override; /** If there's no particular sub-generator set in the INI file, adds the default one, based on the dimension. */ diff --git a/src/Generating/Noise3DGenerator.cpp b/src/Generating/Noise3DGenerator.cpp index 68e3f5377..0826ca764 100644 --- a/src/Generating/Noise3DGenerator.cpp +++ b/src/Generating/Noise3DGenerator.cpp @@ -195,8 +195,9 @@ void cNoise3DGenerator::Initialize(cIniFile & a_IniFile) -void cNoise3DGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) +void cNoise3DGenerator::GenerateBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) { + UNUSED(a_ChunkCoords); for (size_t i = 0; i < ARRAYCOUNT(a_BiomeMap); i++) { a_BiomeMap[i] = biExtremeHills; @@ -207,10 +208,10 @@ void cNoise3DGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::Bi -void cNoise3DGenerator::Generate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc) +void cNoise3DGenerator::Generate(cChunkDesc & a_ChunkDesc) { NOISE_DATATYPE Noise[17 * 257 * 17]; - GenerateNoiseArray(a_ChunkX, a_ChunkZ, Noise); + GenerateNoiseArray(a_ChunkDesc.GetChunkCoords(), Noise); // Output noise into chunk: for (int z = 0; z < cChunkDef::Width; z++) @@ -243,23 +244,21 @@ void cNoise3DGenerator::Generate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_Chun -void cNoise3DGenerator::GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DATATYPE * a_OutNoise) +void cNoise3DGenerator::GenerateNoiseArray(cChunkCoords a_ChunkCoords, NOISE_DATATYPE * a_OutNoise) { NOISE_DATATYPE NoiseO[DIM_X * DIM_Y * DIM_Z]; // Output for the Perlin noise NOISE_DATATYPE NoiseW[DIM_X * DIM_Y * DIM_Z]; // Workspace that the noise calculation can use and trash // Our noise array has different layout, XZY, instead of regular chunk's XYZ, that's why the coords are "renamed" - NOISE_DATATYPE StartX = static_cast<NOISE_DATATYPE>(a_ChunkX * cChunkDef::Width) / m_FrequencyX; - NOISE_DATATYPE EndX = static_cast<NOISE_DATATYPE>((a_ChunkX + 1) * cChunkDef::Width) / m_FrequencyX; - NOISE_DATATYPE StartZ = static_cast<NOISE_DATATYPE>(a_ChunkZ * cChunkDef::Width) / m_FrequencyZ; - NOISE_DATATYPE EndZ = static_cast<NOISE_DATATYPE>((a_ChunkZ + 1) * cChunkDef::Width) / m_FrequencyZ; + NOISE_DATATYPE StartX = static_cast<NOISE_DATATYPE>(a_ChunkCoords.m_ChunkX * cChunkDef::Width) / m_FrequencyX; + NOISE_DATATYPE EndX = static_cast<NOISE_DATATYPE>((a_ChunkCoords.m_ChunkX + 1) * cChunkDef::Width) / m_FrequencyX; + NOISE_DATATYPE StartZ = static_cast<NOISE_DATATYPE>(a_ChunkCoords.m_ChunkZ * cChunkDef::Width) / m_FrequencyZ; + NOISE_DATATYPE EndZ = static_cast<NOISE_DATATYPE>((a_ChunkCoords.m_ChunkZ + 1) * cChunkDef::Width) / m_FrequencyZ; NOISE_DATATYPE StartY = 0; NOISE_DATATYPE EndY = static_cast<NOISE_DATATYPE>(256) / m_FrequencyY; m_Perlin.Generate3D(NoiseO, DIM_X, DIM_Y, DIM_Z, StartX, EndX, StartY, EndY, StartZ, EndZ, NoiseW); - // DEBUG: Debug3DNoise(NoiseO, DIM_X, DIM_Y, DIM_Z, Printf("Chunk_%d_%d_orig", a_ChunkX, a_ChunkZ)); - // Precalculate a "height" array: NOISE_DATATYPE Height[DIM_X * DIM_Z]; // Output for the cubic noise heightmap ("source") m_Cubic.Generate2D(Height, DIM_X, DIM_Z, StartX / 5, EndX / 5, StartZ / 5, EndZ / 5); @@ -283,15 +282,11 @@ void cNoise3DGenerator::GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DAT } } - // DEBUG: Debug3DNoise(NoiseO, DIM_X, DIM_Y, DIM_Z, Printf("Chunk_%d_%d_hei", a_ChunkX, a_ChunkZ)); - // Upscale the Perlin noise into full-blown chunk dimensions: LinearUpscale3DArray( NoiseO, DIM_X, DIM_Y, DIM_Z, a_OutNoise, UPSCALE_X, UPSCALE_Y, UPSCALE_Z ); - - // DEBUG: Debug3DNoise(a_OutNoise, 17, 257, 17, Printf("Chunk_%d_%d_lerp", a_ChunkX, a_ChunkZ)); } diff --git a/src/Generating/Noise3DGenerator.h b/src/Generating/Noise3DGenerator.h index 1f7123588..80e328214 100644 --- a/src/Generating/Noise3DGenerator.h +++ b/src/Generating/Noise3DGenerator.h @@ -30,8 +30,8 @@ public: virtual ~cNoise3DGenerator() override; virtual void Initialize(cIniFile & a_IniFile) override; - virtual void GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; - virtual void Generate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc) override; + virtual void GenerateBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) override; + virtual void Generate(cChunkDesc & a_ChunkDesc) override; protected: // Linear interpolation step sizes, must be divisors of cChunkDef::Width and cChunkDef::Height, respectively: @@ -58,8 +58,8 @@ protected: NOISE_DATATYPE m_FrequencyZ; NOISE_DATATYPE m_AirThreshold; - /** Generates the 3D noise array used for terrain generation; a_Noise is of ChunkData-size */ - void GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DATATYPE * a_Noise); + /** Generates the 3D noise array used for terrain generation into a_Noise; a_Noise is of ChunkData-size */ + void GenerateNoiseArray(cChunkCoords a_ChunkCoords, NOISE_DATATYPE * a_Noise); /** Composes terrain - adds dirt, grass and sand */ void ComposeTerrain(cChunkDesc & a_ChunkDesc); |