diff options
author | Mattes D <github@xoft.cz> | 2019-09-07 11:04:19 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2019-09-07 13:38:07 +0200 |
commit | f50c6735f83908abe49737e115957e2d0909aefb (patch) | |
tree | b1797ed71934be0335d0ede9ccc6e09cc343f7c1 /src | |
parent | Added a BasicGeneratorTest. (diff) | |
download | cuberite-f50c6735f83908abe49737e115957e2d0909aefb.tar cuberite-f50c6735f83908abe49737e115957e2d0909aefb.tar.gz cuberite-f50c6735f83908abe49737e115957e2d0909aefb.tar.bz2 cuberite-f50c6735f83908abe49737e115957e2d0909aefb.tar.lz cuberite-f50c6735f83908abe49737e115957e2d0909aefb.tar.xz cuberite-f50c6735f83908abe49737e115957e2d0909aefb.tar.zst cuberite-f50c6735f83908abe49737e115957e2d0909aefb.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Generating/CompoGen.cpp | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 5659876c6..899ff54c1 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -246,16 +246,12 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc: // Interpolate the lowest floor: for (int z = 0; z <= 16 / INTERPOL_Z; z++) for (int x = 0; x <= 16 / INTERPOL_X; x++) { - //* - FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = + // We need to store the intermediate result in a volatile variable, otherwise gcc -O2 optimizes + // through the undefined behavior in cNoise and produces different data than the other platforms / build types (#4384) + volatile int intermediate = m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) * - m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) / - 256; - //*/ - /* - FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = - m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) / 256; - //*/ + m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z); + FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = intermediate / 256; } // for x, z - FloorLo[] LinearUpscale2DArrayInPlace<17, 17, INTERPOL_X, INTERPOL_Z>(FloorLo); @@ -265,16 +261,12 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc: // First update the high floor: for (int z = 0; z <= 16 / INTERPOL_Z; z++) for (int x = 0; x <= 16 / INTERPOL_X; x++) { - //* - FloorHi[INTERPOL_X * x + 17 * INTERPOL_Z * z] = + // We need to store the intermediate result in a volatile variable, otherwise gcc -O2 optimizes + // through the undefined behavior in cNoise and produces different data than the other platforms / build types (#4384) + volatile int intermediate = m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) * - m_Noise2.IntNoise3DInt(BaseX + INTERPOL_Z * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) / - 256; - //*/ - /* - FloorHi[INTERPOL_X * x + 17 * INTERPOL_Z * z] = - m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) / 256; - //*/ + m_Noise2.IntNoise3DInt(BaseX + INTERPOL_Z * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z); + FloorHi[INTERPOL_X * x + 17 * INTERPOL_Z * z] = intermediate / 256; } // for x, z - FloorLo[] LinearUpscale2DArrayInPlace<17, 17, INTERPOL_X, INTERPOL_Z>(FloorHi); @@ -287,7 +279,7 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc: for (int y = 0; y < SEGMENT_HEIGHT; y++) { int Val = Lo + (Hi - Lo) * y / SEGMENT_HEIGHT; - if (Val < Threshold) // Don't calculate if the block should be Netherrack when it's already decided that it's air. + if (Val < Threshold) { a_ChunkDesc.SetBlockType(x, y + Segment, z, E_BLOCK_NETHERRACK); } @@ -298,7 +290,7 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc: std::swap(FloorLo, FloorHi); } - // Bedrock at the bottom and at the top: + // Bedrock at the bottom and at the top, cover ceiling with netherrack: for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++) { a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK); |