summaryrefslogtreecommitdiffstats
path: root/src/Generating
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-06-10 22:59:45 +0200
committermadmaxoft <github@xoft.cz>2014-06-10 22:59:45 +0200
commit1ff1a93866ab81e3868588a256f446a902a1a8c4 (patch)
tree32dacb18b42599309f428802958f39c2cd6ba405 /src/Generating
parentFixed clang warnings about abs() in Noise.cpp. (diff)
downloadcuberite-1ff1a93866ab81e3868588a256f446a902a1a8c4.tar
cuberite-1ff1a93866ab81e3868588a256f446a902a1a8c4.tar.gz
cuberite-1ff1a93866ab81e3868588a256f446a902a1a8c4.tar.bz2
cuberite-1ff1a93866ab81e3868588a256f446a902a1a8c4.tar.lz
cuberite-1ff1a93866ab81e3868588a256f446a902a1a8c4.tar.xz
cuberite-1ff1a93866ab81e3868588a256f446a902a1a8c4.tar.zst
cuberite-1ff1a93866ab81e3868588a256f446a902a1a8c4.zip
Diffstat (limited to 'src/Generating')
-rw-r--r--src/Generating/DistortedHeightmap.cpp4
-rw-r--r--src/Generating/DistortedHeightmap.h6
-rw-r--r--src/Generating/HeiGen.cpp89
-rw-r--r--src/Generating/HeiGen.h21
4 files changed, 116 insertions, 4 deletions
diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp
index eb9fe92ba..e50f36d57 100644
--- a/src/Generating/DistortedHeightmap.cpp
+++ b/src/Generating/DistortedHeightmap.cpp
@@ -282,7 +282,7 @@ cDistortedHeightmap::cDistortedHeightmap(int a_Seed, cBiomeGen & a_BiomeGen) :
m_OceanFloorSelect(a_Seed + 3000),
m_MesaFloor(a_Seed + 4000),
m_BiomeGen(a_BiomeGen),
- m_UnderlyingHeiGen(a_Seed, a_BiomeGen),
+ m_UnderlyingHeiGen(a_Seed),
m_HeightGen(m_UnderlyingHeiGen, 64),
m_IsInitialized(false)
{
@@ -308,6 +308,8 @@ void cDistortedHeightmap::Initialize(cIniFile & a_IniFile)
return;
}
+ ((cTerrainHeightGen &)m_UnderlyingHeiGen).InitializeHeightGen(a_IniFile);
+
// Read the params from the INI file:
m_SeaLevel = a_IniFile.GetValueSetI("Generator", "DistortedHeightmapSeaLevel", 62);
m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "DistortedHeightmapFrequencyX", 10);
diff --git a/src/Generating/DistortedHeightmap.h b/src/Generating/DistortedHeightmap.h
index e6b3c9d3f..31fb17df2 100644
--- a/src/Generating/DistortedHeightmap.h
+++ b/src/Generating/DistortedHeightmap.h
@@ -64,9 +64,9 @@ protected:
int m_CurChunkZ;
NOISE_DATATYPE m_DistortedHeightmap[17 * 257 * 17];
- cBiomeGen & m_BiomeGen;
- cHeiGenBiomal m_UnderlyingHeiGen; // This generator provides us with base heightmap (before distortion)
- cHeiGenCache m_HeightGen; // Cache above m_UnderlyingHeiGen
+ cBiomeGen & m_BiomeGen;
+ cHeiGenMesaBryce m_UnderlyingHeiGen; // This generator provides us with base heightmap (before distortion)
+ cHeiGenCache m_HeightGen; // Cache above m_UnderlyingHeiGen
/// Heightmap for the current chunk, before distortion (from m_HeightGen). Used for optimization.
cChunkDef::HeightMap m_CurChunkHeights;
diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp
index 25ac912fd..dedf3fe3f 100644
--- a/src/Generating/HeiGen.cpp
+++ b/src/Generating/HeiGen.cpp
@@ -47,6 +47,10 @@ cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBio
{
res = new cEndGen(a_Seed);
}
+ else if (NoCaseCompare(HeightGenName, "MesaBryce") == 0)
+ {
+ res = new cHeiGenMesaBryce(a_Seed);
+ }
else if (NoCaseCompare(HeightGenName, "Mountains") == 0)
{
res = new cHeiGenMountains(a_Seed);
@@ -367,6 +371,91 @@ void cHeiGenMountains::InitializeHeightGen(cIniFile & a_IniFile)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cHeiGenMesaBryce:
+
+cHeiGenMesaBryce::cHeiGenMesaBryce(int a_Seed) :
+ m_Seed(a_Seed),
+ m_PerlinHFHA(a_Seed),
+ m_PerlinLFLA(a_Seed + 10)
+{
+}
+
+
+
+
+
+void cHeiGenMesaBryce::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
+{
+ NOISE_DATATYPE StartX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width);
+ NOISE_DATATYPE EndX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + cChunkDef::Width - 1);
+ NOISE_DATATYPE StartZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width);
+ NOISE_DATATYPE EndZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + cChunkDef::Width - 1);
+ NOISE_DATATYPE Workspace[16 * 16];
+ NOISE_DATATYPE Noise1[16 * 16];
+ NOISE_DATATYPE Noise2[16 * 16];
+ NOISE_DATATYPE Noise3[16 * 16];
+ m_PerlinHFHA.Generate2D(Noise1, 16, 16, StartX, EndX, StartZ, EndZ, Workspace);
+ m_PerlinLFLA.Generate2D(Noise2, 16, 16, StartX, EndX, StartZ, EndZ, Workspace);
+ m_PerlinTops.Generate2D(Noise3, 16, 16, StartX, EndX, StartZ, EndZ, Workspace);
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ int IdxZ = z * cChunkDef::Width;
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ int idx = IdxZ + x;
+ // int hei = 70 + (int)(std::min(Noise1[idx], Noise2[idx]) * 15);
+ int hei;
+ if (Noise1[idx] > 1.5f)
+ {
+ hei = 83 + (int)floor(Noise3[idx]);
+ }
+ else
+ {
+ hei = 63 + (int)floor(Noise2[idx]);
+ }
+ /*
+ NOISE_DATATYPE v1 = sqrt(sqrt(std::max(Noise1[idx], (NOISE_DATATYPE)0))) - 50;
+ int hei = 60 + (int)floor(std::max(v1, 5 + Noise2[idx]));
+ */
+ if (hei < 10)
+ {
+ hei = 10;
+ }
+ if (hei > 250)
+ {
+ hei = 250;
+ }
+ cChunkDef::SetHeight(a_HeightMap, x , z, hei);
+ } // for x
+ } // for z
+}
+
+
+
+
+
+void cHeiGenMesaBryce::InitializeHeightGen(cIniFile & a_IniFile)
+{
+ // TODO: Read the params from an INI file
+ // m_PerlinHFHA.AddOctave(0.32f, 0.1);
+ /*
+ m_PerlinHFHA.AddOctave(0.13f, 17800000);
+ m_PerlinHFHA.AddOctave(0.12f, 19000000);
+ */
+ m_PerlinHFHA.AddOctave(0.13f, 2);
+ m_PerlinHFHA.AddOctave(0.12f, 2);
+
+ m_PerlinLFLA.AddOctave(0.04f, 1);
+ m_PerlinLFLA.AddOctave(0.02f, 2);
+
+ m_PerlinTops.AddOctave(0.1f, 8);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cHeiGenBiomal:
const cHeiGenBiomal::sGenParam cHeiGenBiomal::m_GenParam[256] =
diff --git a/src/Generating/HeiGen.h b/src/Generating/HeiGen.h
index 5c106c7d9..5fc4f4abc 100644
--- a/src/Generating/HeiGen.h
+++ b/src/Generating/HeiGen.h
@@ -127,6 +127,27 @@ protected:
+class cHeiGenMesaBryce :
+ public cTerrainHeightGen
+{
+public:
+ cHeiGenMesaBryce(int a_Seed);
+
+protected:
+ int m_Seed;
+ cPerlinNoise m_PerlinHFHA; // HighFrequencyHighAmplitude, for the hills
+ cPerlinNoise m_PerlinLFLA; // LowFrequencyLowAmplitude, for the floor
+ cPerlinNoise m_PerlinTops;
+
+ // cTerrainHeightGen overrides:
+ virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
+ virtual void InitializeHeightGen(cIniFile & a_IniFile) override;
+} ;
+
+
+
+
+
class cHeiGenBiomal :
public cTerrainHeightGen
{