diff options
author | madmaxoft <github@xoft.cz> | 2014-06-10 22:59:45 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-06-10 22:59:45 +0200 |
commit | 1ff1a93866ab81e3868588a256f446a902a1a8c4 (patch) | |
tree | 32dacb18b42599309f428802958f39c2cd6ba405 /src/Generating/HeiGen.cpp | |
parent | Fixed clang warnings about abs() in Noise.cpp. (diff) | |
download | cuberite-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/HeiGen.cpp')
-rw-r--r-- | src/Generating/HeiGen.cpp | 89 |
1 files changed, 89 insertions, 0 deletions
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] = |