summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-27 16:47:59 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-27 16:47:59 +0200
commitead418967f3007ee3e2a0a99704d90e132c7a4f9 (patch)
tree6aad8d88ad68a7ec43a31be9138cecf95ea9863e
parentFixed a crash in the plugin reload code. (diff)
downloadcuberite-ead418967f3007ee3e2a0a99704d90e132c7a4f9.tar
cuberite-ead418967f3007ee3e2a0a99704d90e132c7a4f9.tar.gz
cuberite-ead418967f3007ee3e2a0a99704d90e132c7a4f9.tar.bz2
cuberite-ead418967f3007ee3e2a0a99704d90e132c7a4f9.tar.lz
cuberite-ead418967f3007ee3e2a0a99704d90e132c7a4f9.tar.xz
cuberite-ead418967f3007ee3e2a0a99704d90e132c7a4f9.tar.zst
cuberite-ead418967f3007ee3e2a0a99704d90e132c7a4f9.zip
-rw-r--r--source/Generating/Noise3DGenerator.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/source/Generating/Noise3DGenerator.cpp b/source/Generating/Noise3DGenerator.cpp
index c4614ffc2..91a9da044 100644
--- a/source/Generating/Noise3DGenerator.cpp
+++ b/source/Generating/Noise3DGenerator.cpp
@@ -55,18 +55,23 @@ void cNoise3DGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::Bi
void cNoise3DGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc)
{
+ // Parameters, TODO: Make some settable in the INI file
const int INTERPOL_X = 8;
const int INTERPOL_Y = 4;
const int INTERPOL_Z = 8;
const NOISE_DATATYPE FrequencyX = 20;
const NOISE_DATATYPE FrequencyY = 20;
const NOISE_DATATYPE FrequencyZ = 20;
+ const NOISE_DATATYPE MidPoint = 75; // Where the vertical "center" of the noise should be
+ const NOISE_DATATYPE AirThreshold = (NOISE_DATATYPE)0.5;
+ const int SeaLevel = 62;
+
NOISE_DATATYPE Noise[257 * 17 * 17]; // x + 17 * z + 17 * 17 * y
int idx = 0;
for (int y = 0; y < 257; y += INTERPOL_Y)
{
NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)y) / FrequencyY;
- NOISE_DATATYPE AddHeight = NoiseY - ((NOISE_DATATYPE)128 / FrequencyY);
+ NOISE_DATATYPE AddHeight = NoiseY - (MidPoint / FrequencyY);
AddHeight *= AddHeight * AddHeight * AddHeight * AddHeight;
NOISE_DATATYPE * CurFloor = &(Noise[y * 17 * 17]);
for (int z = 0; z < 17; z += INTERPOL_Z)
@@ -159,7 +164,17 @@ void cNoise3DGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_Ch
int idx = y * 17 * 17 + z * 17;
for (int x = 0; x < cChunkDef::Width; x++)
{
- a_ChunkDesc.SetBlockType(x, y, z, (Noise[idx++] > 0.5) ? E_BLOCK_AIR : E_BLOCK_STONE);
+ NOISE_DATATYPE n = Noise[idx++];
+ BLOCKTYPE BlockType;
+ if (n > AirThreshold)
+ {
+ BlockType = (y > SeaLevel) ? E_BLOCK_AIR : E_BLOCK_STATIONARY_WATER;
+ }
+ else
+ {
+ BlockType = E_BLOCK_STONE;
+ }
+ a_ChunkDesc.SetBlockType(x, y, z, BlockType);
}
}
}