diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-04-22 21:27:15 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-04-22 21:27:15 +0200 |
commit | d852ea78f978df5295941b1bb2e2dd4138ef2e58 (patch) | |
tree | a9913493212f7c4bb0af0349b1590f9fb91d326a /source/Generating | |
parent | VC2008 project file: enabled multi-threaded compilation of Release and Release-profiled targets (diff) | |
download | cuberite-d852ea78f978df5295941b1bb2e2dd4138ef2e58.tar cuberite-d852ea78f978df5295941b1bb2e2dd4138ef2e58.tar.gz cuberite-d852ea78f978df5295941b1bb2e2dd4138ef2e58.tar.bz2 cuberite-d852ea78f978df5295941b1bb2e2dd4138ef2e58.tar.lz cuberite-d852ea78f978df5295941b1bb2e2dd4138ef2e58.tar.xz cuberite-d852ea78f978df5295941b1bb2e2dd4138ef2e58.tar.zst cuberite-d852ea78f978df5295941b1bb2e2dd4138ef2e58.zip |
Diffstat (limited to '')
-rw-r--r-- | source/Generating/CompoGen.cpp | 53 | ||||
-rw-r--r-- | source/Generating/CompoGen.h | 3 | ||||
-rw-r--r-- | source/Generating/HeiGen.cpp | 6 |
3 files changed, 37 insertions, 25 deletions
diff --git a/source/Generating/CompoGen.cpp b/source/Generating/CompoGen.cpp index 2e0ec5d18..4997910ed 100644 --- a/source/Generating/CompoGen.cpp +++ b/source/Generating/CompoGen.cpp @@ -192,6 +192,13 @@ void cCompoGenBiomal::ComposeTerrain(cChunkDesc & a_ChunkDesc) int ChunkX = a_ChunkDesc.GetChunkX(); int ChunkZ = a_ChunkDesc.GetChunkZ(); + + /* + _X 2013_04_22: + There's no point in generating the whole cubic noise at once, because the noise values are used in + only about 20 % of the cases, so the speed gained by precalculating is lost by precalculating too much data + */ + for (int z = 0; z < cChunkDef::Width; z++) { for (int x = 0; x < cChunkDef::Width; x++) @@ -256,7 +263,14 @@ void cCompoGenBiomal::ComposeTerrain(cChunkDesc & a_ChunkDesc) default: { // Fill with water, sand/dirt/clay mix and stone - FillColumnWaterMix(ChunkX, ChunkZ, x, z, Height, a_ChunkDesc.GetBlockTypes()); + if (m_Noise.CubicNoise2D(0.1f * (cChunkDef::Width * ChunkX + x), 0.1f * (cChunkDef::Width * ChunkZ + z)) < 0) + { + FillColumnWaterSand(x, z, Height, a_ChunkDesc.GetBlockTypes()); + } + else + { + FillColumnWaterDirt(x, z, Height, a_ChunkDesc.GetBlockTypes()); + } break; } } // switch (biome) @@ -347,32 +361,25 @@ void cCompoGenBiomal::FillColumnWaterSand(int a_RelX, int a_RelZ, int a_Height, -void cCompoGenBiomal::FillColumnWaterMix(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes) +void cCompoGenBiomal::FillColumnWaterDirt(int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes) { - if (m_Noise.CubicNoise2D(0.5f * (cChunkDef::Width * a_ChunkX + a_RelX), 0.5f * (cChunkDef::Width * a_ChunkZ + a_RelZ)) < 0) + // Dirt + BLOCKTYPE Pattern[] = + { + E_BLOCK_DIRT, + E_BLOCK_DIRT, + E_BLOCK_DIRT, + E_BLOCK_DIRT, + } ; + FillColumnPattern(a_RelX, a_RelZ, a_Height, a_BlockTypes, Pattern, ARRAYCOUNT(Pattern)); + + for (int y = a_Height - ARRAYCOUNT(Pattern); y > 0; y--) { - FillColumnWaterSand(a_RelX, a_RelZ, a_Height, a_BlockTypes); + cChunkDef::SetBlock(a_BlockTypes, a_RelX, y, a_RelZ, E_BLOCK_STONE); } - else + for (int y = a_Height + 1; y <= m_SeaLevel + 1; y++) { - // Dirt - BLOCKTYPE Pattern[] = - { - E_BLOCK_DIRT, - E_BLOCK_DIRT, - E_BLOCK_DIRT, - E_BLOCK_DIRT, - } ; - FillColumnPattern(a_RelX, a_RelZ, a_Height, a_BlockTypes, Pattern, ARRAYCOUNT(Pattern)); - - for (int y = a_Height - ARRAYCOUNT(Pattern); y > 0; y--) - { - cChunkDef::SetBlock(a_BlockTypes, a_RelX, y, a_RelZ, E_BLOCK_STONE); - } - for (int y = a_Height + 1; y <= m_SeaLevel + 1; y++) - { - cChunkDef::SetBlock(a_BlockTypes, a_RelX, y, a_RelZ, E_BLOCK_STATIONARY_WATER); - } + cChunkDef::SetBlock(a_BlockTypes, a_RelX, y, a_RelZ, E_BLOCK_STATIONARY_WATER); } } diff --git a/source/Generating/CompoGen.h b/source/Generating/CompoGen.h index 9880ce1a0..57233e2fd 100644 --- a/source/Generating/CompoGen.h +++ b/source/Generating/CompoGen.h @@ -111,8 +111,7 @@ protected: void FillColumnSand (int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes); void FillColumnMycelium (int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes); void FillColumnWaterSand(int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes); - - void FillColumnWaterMix (int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes); + void FillColumnWaterDirt(int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes); void FillColumnPattern (int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes, const BLOCKTYPE * a_Pattern, int a_PatternSize); } ; diff --git a/source/Generating/HeiGen.cpp b/source/Generating/HeiGen.cpp index 085459ad7..baf013a16 100644 --- a/source/Generating/HeiGen.cpp +++ b/source/Generating/HeiGen.cpp @@ -229,6 +229,12 @@ void cHeiGenBiomal::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMa } // for z /* + _X 2013_04_22: + There's no point in precalculating the entire perlin noise arrays, too many values are calculated uselessly, + resulting in speed DEcrease. + */ + + /* // Linearly interpolate 4x4 blocks of heightmap: // This is fast, but really ugly! Do not use! const int STEPZ = 4; // Must be a divisor of 16 |