From 23021dd8287ae17a5653040114c875b46a63a398 Mon Sep 17 00:00:00 2001 From: NiLSPACE Date: Sun, 4 Oct 2020 17:12:36 +0200 Subject: [PATCH] Fixed current end generator (#4968) --- src/Generating/EndGen.cpp | 38 ++------------------------------------ src/Generating/EndGen.h | 8 -------- 2 files changed, 2 insertions(+), 44 deletions(-) diff --git a/src/Generating/EndGen.cpp b/src/Generating/EndGen.cpp index 82dc5c414..4e5e1a809 100644 --- a/src/Generating/EndGen.cpp +++ b/src/Generating/EndGen.cpp @@ -40,10 +40,6 @@ cEndGen::cEndGen(int a_Seed) : m_FrequencyX(80), m_FrequencyY(80), m_FrequencyZ(80), - m_MinChunkX(0), - m_MaxChunkX(0), - m_MinChunkZ(0), - m_MaxChunkZ(0), m_LastChunkCoords(0x7fffffff, 0x7fffffff) // Use dummy coords that won't ever be used by real chunks { m_Perlin.AddOctave(1, 1); @@ -64,12 +60,6 @@ void cEndGen::InitializeCompoGen(cIniFile & a_IniFile) m_FrequencyX = static_cast(a_IniFile.GetValueSetF("Generator", "EndGenFrequencyX", m_FrequencyX)); m_FrequencyY = static_cast(a_IniFile.GetValueSetF("Generator", "EndGenFrequencyY", m_FrequencyY)); m_FrequencyZ = static_cast(a_IniFile.GetValueSetF("Generator", "EndGenFrequencyZ", m_FrequencyZ)); - - // Recalculate the min and max chunk coords of the island - m_MaxChunkX = (m_IslandSizeX + cChunkDef::Width - 1) / cChunkDef::Width; - m_MinChunkX = -m_MaxChunkX; - m_MaxChunkZ = (m_IslandSizeZ + cChunkDef::Width - 1) / cChunkDef::Width; - m_MinChunkZ = -m_MaxChunkZ; } @@ -78,8 +68,6 @@ void cEndGen::InitializeCompoGen(cIniFile & a_IniFile) void cEndGen::PrepareState(cChunkCoords a_ChunkCoords) { - ASSERT(!IsChunkOutsideRange(a_ChunkCoords)); // Should be filtered before calling this function - if (m_LastChunkCoords == a_ChunkCoords) { return; @@ -136,30 +124,8 @@ void cEndGen::GenerateNoiseArray(void) -bool cEndGen::IsChunkOutsideRange(cChunkCoords a_ChunkCoords) -{ - return ( - (a_ChunkCoords.m_ChunkX < m_MinChunkX) || (a_ChunkCoords.m_ChunkX > m_MaxChunkX) || - (a_ChunkCoords.m_ChunkZ < m_MinChunkZ) || (a_ChunkCoords.m_ChunkZ > m_MaxChunkZ) - ); -} - - - - - void cEndGen::GenShape(cChunkCoords a_ChunkCoords, cChunkDesc::Shape & a_Shape) { - // If the chunk is outside out range, fill the shape with zeroes: - if (IsChunkOutsideRange(a_ChunkCoords)) - { - for (size_t i = 0; i < ARRAYCOUNT(a_Shape); i++) - { - a_Shape[i] = 0; - } - return; - } - PrepareState(a_ChunkCoords); int MaxY = std::min(static_cast(1.75 * m_IslandSizeY + 1), cChunkDef::Height - 1); @@ -169,11 +135,11 @@ void cEndGen::GenShape(cChunkCoords a_ChunkCoords, cChunkDesc::Shape & a_Shape) { for (int y = 0; y < MaxY; y++) { - a_Shape[(x + 16 * z) * 256 + y] = (m_NoiseArray[y * 17 * 17 + z * 17 + z] > 0) ? 1 : 0; + a_Shape[y + x * 256 + z * 256 * 16] = (m_NoiseArray[y * 17 * 17 + z * 17 + x] <= 0) ? 1 : 0; } for (int y = MaxY; y < cChunkDef::Height; y++) { - a_Shape[(x + 16 * z) * 256 + y] = 0; + a_Shape[y + x * 256 + z * 256 * 16] = 0; } } // for x } // for z diff --git a/src/Generating/EndGen.h b/src/Generating/EndGen.h index f3d9fde7b..c1c6f00b6 100644 --- a/src/Generating/EndGen.h +++ b/src/Generating/EndGen.h @@ -41,10 +41,6 @@ protected: NOISE_DATATYPE m_FrequencyY; NOISE_DATATYPE m_FrequencyZ; - // Minimum and maximum chunk coords for chunks inside the island area. Chunks outside won't get calculated at all - int m_MinChunkX, m_MaxChunkX; - int m_MinChunkZ, m_MaxChunkZ; - // Noise array for the last chunk (in the noise range) cChunkCoords m_LastChunkCoords; NOISE_DATATYPE m_NoiseArray[17 * 17 * 257]; // x + 17 * z + 17 * 17 * y @@ -56,10 +52,6 @@ protected: /** Generates the m_NoiseArray array for the current chunk */ void GenerateNoiseArray(void); - /** Returns true if the chunk is outside of the island's dimensions */ - bool IsChunkOutsideRange(cChunkCoords a_ChunkCoords); - - // cTerrainShapeGen overrides: virtual void GenShape(cChunkCoords a_ChunkCoords, cChunkDesc::Shape & a_Shape) override;