From 9080f14dc2a1010d4169ba690c4bda8da1188ae9 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 23 Jul 2014 11:02:42 +0200 Subject: Fixed possible crash in the NetherClumpFoliage finisher. --- src/Generating/FinishGen.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Generating/FinishGen.cpp') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 444af5022..c67cc574e 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -125,6 +125,11 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a float zz = (float) a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; for (int y = a_RelY - 2; y < a_RelY + 2; y++) { + if ((y < 1) || (y > cChunkDef::Height)) + { + continue; + } + if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks. { continue; -- cgit v1.2.3 From 0f298c8b84756cf5bc055ff82d43ffa9ea8d577b Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 25 Jul 2014 14:23:36 +0200 Subject: Speed up the NetherClumpFoliage finisher. Using IntNoiseXX instead of CubicNoiseXX. --- src/Generating/FinishGen.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/Generating/FinishGen.cpp') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index c67cc574e..b2585bfee 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -48,8 +48,8 @@ void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc) double ChunkX = a_ChunkDesc.GetChunkX() + 0.1; // We can't devide through 0 so lets add 0.1 to all the chunk coordinates. double ChunkZ = a_ChunkDesc.GetChunkZ() + 0.1; - NOISE_DATATYPE Val1 = m_Noise.CubicNoise2D((float) (ChunkX * ChunkZ * 0.01f), (float) (ChunkZ / ChunkX * 0.01f)); - NOISE_DATATYPE Val2 = m_Noise.CubicNoise2D((float) (ChunkX / ChunkZ / 0.01f), (float) (ChunkZ * ChunkX / 0.01f)); + NOISE_DATATYPE Val1 = m_Noise.IntNoise2D((int) (ChunkX * ChunkZ * 0.01f), (int) (ChunkZ / ChunkX * 0.01f)); + NOISE_DATATYPE Val2 = m_Noise.IntNoise2D((int) (ChunkX / ChunkZ / 0.01f), (int) (ChunkZ * ChunkX / 0.01f)); if (Val1 < 0) { @@ -88,12 +88,14 @@ void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc) { continue; } + if (!cBlockInfo::IsSolid(a_ChunkDesc.GetBlockType(PosX, y - 1, PosZ))) // Only place on solid blocks { continue; } - NOISE_DATATYPE BlockType = m_Noise.CubicNoise1D((float) (ChunkX * ChunkZ) / (y * 0.1f)); + // Choose what block to use. + NOISE_DATATYPE BlockType = m_Noise.IntNoise3D((int) ChunkX, y, (int) ChunkZ); if (BlockType < -0.7) { TryPlaceClump(a_ChunkDesc, PosX, y, PosZ, E_BLOCK_BROWN_MUSHROOM); @@ -119,10 +121,10 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a for (int x = a_RelX - 4; x < a_RelX + 4; x++) { - float xx = (float) a_ChunkDesc.GetChunkX() * cChunkDef::Width + x; + int xx = a_ChunkDesc.GetChunkX() * cChunkDef::Width + x; for (int z = a_RelZ - 4; z < a_RelZ + 4; z++) { - float zz = (float) a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; + int zz = a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; for (int y = a_RelY - 2; y < a_RelY + 2; y++) { if ((y < 1) || (y > cChunkDef::Height)) @@ -149,9 +151,8 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a } } - - NOISE_DATATYPE Val = m_Noise.CubicNoise2D(xx, zz); - if (Val < -0.70) + NOISE_DATATYPE Val = m_Noise.IntNoise2D(xx, zz); + if (Val < -0.5) { a_ChunkDesc.SetBlockType(x, y, z, a_Block); } -- cgit v1.2.3 From a39e19e94a1086cc2c5974cecc5d383cd26b3d12 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 25 Jul 2014 21:01:40 +0200 Subject: Tweaks to NetherClumpFoliage Simplefied the way NetherClupFoliage creates the X and Z coordinate. --- src/Generating/FinishGen.cpp | 40 ++++++---------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) (limited to 'src/Generating/FinishGen.cpp') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index b2585bfee..4c40270e8 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -45,42 +45,14 @@ static inline bool IsWater(BLOCKTYPE a_BlockType) void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc) { - double ChunkX = a_ChunkDesc.GetChunkX() + 0.1; // We can't devide through 0 so lets add 0.1 to all the chunk coordinates. - double ChunkZ = a_ChunkDesc.GetChunkZ() + 0.1; - - NOISE_DATATYPE Val1 = m_Noise.IntNoise2D((int) (ChunkX * ChunkZ * 0.01f), (int) (ChunkZ / ChunkX * 0.01f)); - NOISE_DATATYPE Val2 = m_Noise.IntNoise2D((int) (ChunkX / ChunkZ / 0.01f), (int) (ChunkZ * ChunkX / 0.01f)); + int ChunkX = a_ChunkDesc.GetChunkX(); + int ChunkZ = a_ChunkDesc.GetChunkZ(); - if (Val1 < 0) - { - Val1 = -Val1; - } - - if (Val2 < 0) - { - Val2 = -Val2; - } + int Val1 = m_Noise.IntNoise2DInt(ChunkX ^ ChunkZ, ChunkZ + ChunkX); + int Val2 = m_Noise.IntNoise2DInt(ChunkZ ^ ChunkX, ChunkZ - ChunkX); - int PosX, PosZ; - // Calculate PosX - if (Val1 <= 1) - { - PosX = (int) floor(Val1 * 16); - } - else - { - PosX = (int) floor(16 / Val1); - } - - // Calculate PosZ - if (Val2 <= 1) - { - PosZ = (int) floor(Val2 * 16); - } - else - { - PosZ = (int) floor(16 / Val2); - } + int PosX = Val1 % 16; + int PosZ = Val2 % 16; for (int y = 1; y < cChunkDef::Height; y++) { -- cgit v1.2.3 From 50fc1a54699b437aa7f5fccc22f594707d31238d Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 27 Jul 2014 11:59:54 +0200 Subject: NetherClumpFoliage: Fixed assert --- src/Generating/FinishGen.cpp | 47 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) (limited to 'src/Generating/FinishGen.cpp') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 4c40270e8..03137f616 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -91,19 +91,50 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a { bool IsFireBlock = a_Block == E_BLOCK_FIRE; - for (int x = a_RelX - 4; x < a_RelX + 4; x++) + int MinX = a_RelX - 4; + if (MinX < 0) // Check if the coordinate is outside the chunk. If it it then adjust it. + { + MinX = 0; + } + + int MaxX = a_RelX + 4; + if (MaxX > cChunkDef::Width) // Check if the coordinate is outside the chunk. If it it then adjust it. + { + MaxX = cChunkDef::Width; + } + + int MinZ = a_RelZ - 4; + if (MinZ < 0) // Check if the coordinate is outside the chunk. If it it then adjust it. + { + MinZ = 0; + } + + int MaxZ = a_RelZ + 4; + if (MaxZ > cChunkDef::Width) // Check if the coordinate is outside the chunk. If it it then adjust it. + { + MaxZ = cChunkDef::Width; + } + + int MinY = a_RelY - 2; + if (MinY < 0) // Check if the coordinate is outside the chunk. If it it then adjust it. + { + MinY = 0; + } + + int MaxY = a_RelY + 2; + if (MaxY > cChunkDef::Height) // Check if the coordinate is outside the chunk. If it it then adjust it. + { + MaxY = cChunkDef::Height; + } + + for (int x = MinX; x < MaxX; x++) { int xx = a_ChunkDesc.GetChunkX() * cChunkDef::Width + x; - for (int z = a_RelZ - 4; z < a_RelZ + 4; z++) + for (int z = MinZ; z < MaxZ; z++) { int zz = a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; - for (int y = a_RelY - 2; y < a_RelY + 2; y++) + for (int y = MinY; y < MaxY; y++) { - if ((y < 1) || (y > cChunkDef::Height)) - { - continue; - } - if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks. { continue; -- cgit v1.2.3 From d61f1d0f4a1565d4de7e8100d9bf766d6fd458d1 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 27 Jul 2014 20:48:39 +0200 Subject: NetherClumpGenerator: Fixed generating stuff on halfslabs and fences --- src/Generating/FinishGen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Generating/FinishGen.cpp') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 03137f616..9f0c8f3fa 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -141,7 +141,7 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a } BLOCKTYPE BlockBelow = a_ChunkDesc.GetBlockType(x, y - 1, z); - if (!cBlockInfo::IsSolid(BlockBelow)) // Only place on solid blocks + if (!cBlockInfo::FullyOccupiesVoxel(BlockBelow)) // Only place on solid blocks { continue; } -- cgit v1.2.3