summaryrefslogtreecommitdiffstats
path: root/source/Generating/DistortedHeightmap.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-04 14:43:30 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-04 14:43:30 +0200
commitc52f03fe4a87ac766f567b0c6b7e9a5a3b3e3cd9 (patch)
tree69566f32f6890123010c9315b27908142aec4359 /source/Generating/DistortedHeightmap.cpp
parentFixed a crash when generating a chest (diff)
downloadcuberite-c52f03fe4a87ac766f567b0c6b7e9a5a3b3e3cd9.tar
cuberite-c52f03fe4a87ac766f567b0c6b7e9a5a3b3e3cd9.tar.gz
cuberite-c52f03fe4a87ac766f567b0c6b7e9a5a3b3e3cd9.tar.bz2
cuberite-c52f03fe4a87ac766f567b0c6b7e9a5a3b3e3cd9.tar.lz
cuberite-c52f03fe4a87ac766f567b0c6b7e9a5a3b3e3cd9.tar.xz
cuberite-c52f03fe4a87ac766f567b0c6b7e9a5a3b3e3cd9.tar.zst
cuberite-c52f03fe4a87ac766f567b0c6b7e9a5a3b3e3cd9.zip
Diffstat (limited to '')
-rw-r--r--source/Generating/DistortedHeightmap.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/source/Generating/DistortedHeightmap.cpp b/source/Generating/DistortedHeightmap.cpp
index b81db61cc..5efc27895 100644
--- a/source/Generating/DistortedHeightmap.cpp
+++ b/source/Generating/DistortedHeightmap.cpp
@@ -57,6 +57,7 @@ const cDistortedHeightmap::sGenParam cDistortedHeightmap::m_GenParam[biNumBiomes
cDistortedHeightmap::cDistortedHeightmap(int a_Seed, cBiomeGen & a_BiomeGen) :
m_NoiseDistortX(a_Seed + 1000),
m_NoiseDistortZ(a_Seed + 2000),
+ m_OceanFloorSelect(a_Seed + 3000),
m_BiomeGen(a_BiomeGen),
m_UnderlyingHeiGen(a_Seed, a_BiomeGen),
m_HeightGen(&m_UnderlyingHeiGen, 64)
@@ -185,7 +186,14 @@ void cDistortedHeightmap::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::He
void cDistortedHeightmap::ComposeTerrain(cChunkDesc & a_ChunkDesc)
{
+ // Frequencies for the ocean floor selecting noise:
+ NOISE_DATATYPE FrequencyX = 3;
+ NOISE_DATATYPE FrequencyZ = 3;
+
+ // Prepare the internal state for generating this chunk:
PrepareState(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ());
+
+ // Compose:
a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0);
for (int z = 0; z < cChunkDef::Width; z++)
{
@@ -217,8 +225,42 @@ void cDistortedHeightmap::ComposeTerrain(cChunkDesc & a_ChunkDesc)
}
if (HasHadWater)
{
- // TODO: Decide between sand and dirt
- a_ChunkDesc.SetBlockType(x, y, z, (y < LastAir - 3) ? E_BLOCK_SANDSTONE : E_BLOCK_SAND);
+ // Decide between clay, sand and dirt
+ NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width + x)) / FrequencyX;
+ NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width + z)) / FrequencyZ;
+ NOISE_DATATYPE Val = m_OceanFloorSelect.CubicNoise2D(NoiseX, NoiseY);
+ if (Val < -0.95)
+ {
+ // Clay:
+ switch (LastAir - y)
+ {
+ case 0:
+ case 1:
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_CLAY);
+ break;
+ }
+ case 2:
+ case 3:
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_SAND);
+ break;
+ }
+ case 4:
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_SANDSTONE);
+ break;
+ }
+ } // switch (floor depth)
+ }
+ else if (Val < 0)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, (y < LastAir - 3) ? E_BLOCK_SANDSTONE : E_BLOCK_SAND);
+ }
+ else
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_DIRT);
+ }
}
else
{