8 #include "../LinearUpscale.h" 9 #include "../IniFile.h" 30 std::make_shared<cProtIntGenWeightAvg<16, 1, 0>>(
31 std::make_shared<cProtIntGenSmooth> (a_Seed + 1,
32 std::make_shared<cProtIntGenZoom> (a_Seed + 2,
33 std::make_shared<cProtIntGenSmooth> (a_Seed + 3,
34 std::make_shared<cProtIntGenZoom> (a_Seed + 4,
35 std::make_shared<cProtIntGenAddRnd> (a_Seed + 5, 1,
36 std::make_shared<cProtIntGenSmooth> (a_Seed + 6,
37 std::make_shared<cProtIntGenZoom> (a_Seed + 7,
38 std::make_shared<cProtIntGenRndBetween> (a_Seed + 8, 60,
39 std::make_shared<cProtIntGenAddRnd> (a_Seed + 9, 1,
40 std::make_shared<cProtIntGenSmooth> (a_Seed + 1,
41 std::make_shared<cProtIntGenZoom> (a_Seed + 2,
42 std::make_shared<cProtIntGenRndBetween> (a_Seed + 3, 60,
43 std::make_shared<cProtIntGenSmooth> (a_Seed + 4,
44 std::make_shared<cProtIntGenZoom> (a_Seed + 5,
45 std::make_shared<cProtIntGenRndBetween> (a_Seed + 6, 60,
46 std::make_shared<cProtIntGenRndChoice> (a_Seed + 7, 10, 50, 50,
47 std::make_shared<cProtIntGenSmooth> (a_Seed + 8,
48 std::make_shared<cProtIntGenZoom> (a_Seed + 9,
49 std::make_shared<cProtIntGenRndChoice> (a_Seed + 1, 10, 50, 50,
50 std::make_shared<cProtIntGenAddRnd> (a_Seed + 2, 2,
51 std::make_shared<cProtIntGenZoom> (a_Seed + 3,
52 std::make_shared<cProtIntGenZoom> (a_Seed + 4,
53 std::make_shared<cProtIntGenChoice> (a_Seed + 5, 10)
54 )))))))))))))))))))))));
65 for (
size_t i = 0; i <
ARRAYCOUNT(heights); i++)
74 std::shared_ptr<cProtIntGen>
m_Gen;
87 for (
size_t i = 0; i <
ARRAYCOUNT(a_HeightMap); i++)
89 a_HeightMap[i] = m_Height;
110 m_HeiGenToCache(a_HeiGenToCache),
111 m_CacheSize(a_CacheSize),
148 for (
size_t j = i; j > 0; j--)
155 memcpy(a_HeightMap,
m_CacheData[Idx].m_HeightMap,
sizeof(a_HeightMap));
168 for (
auto i = m_CacheSize - 1; i > 0; i--)
173 memcpy(
m_CacheData[Idx].m_HeightMap, a_HeightMap,
sizeof(a_HeightMap));
195 return cChunkDef::GetHeight(heightMap, a_BlockX - chunkX * cChunkDef::Width, a_BlockZ - chunkZ * cChunkDef::Width);
223 m_NumSubCaches(a_NumSubCaches)
227 for (
size_t i = 0; i < a_NumSubCaches; i++)
229 m_SubCaches.push_back(std::make_shared<cHeiGenCache>(a_HeiGenToCache, a_SubCacheSize));
243 m_SubCaches[cacheIdx]->GenHeightMap(a_ChunkCoords, a_HeightMap);
264 return cChunkDef::GetHeight(heightMap, a_BlockX - chunkX * cChunkDef::Width, a_BlockZ - chunkZ * cChunkDef::Width);
274 const size_t cacheIdx = (
static_cast<size_t>(a_ChunkX) +
m_CoeffZ * static_cast<size_t>(a_ChunkZ)) %
m_NumSubCaches;
277 return m_SubCaches[cacheIdx]->GetHeightAt(a_ChunkX, a_ChunkZ, a_RelX, a_RelZ, a_Height);
312 flatness *= flatness * flatness;
314 return (oct1 + oct2 + oct3) * flatness + height;
325 const float zz =
static_cast<float>(a_ChunkCoords.
m_ChunkZ * cChunkDef::Width + z);
328 const float xx =
static_cast<float>(a_ChunkCoords.
m_ChunkX * cChunkDef::Width + x);
359 m_MountainNoise(a_Seed + 100),
360 m_DitchNoise(a_Seed + 200),
361 m_Perlin(a_Seed + 300)
388 HEIGHTTYPE hei =
static_cast<HEIGHTTYPE>(
Clamp(100 - static_cast<int>((MountainNoise[idx] - DitchNoise[idx] + PerlinNoise[idx]) * 15), 10, 250));
422 { 0.1f, 2.0f, 0.05f, 10.0f, 0.01f, 8.0f, 50},
423 { 0.1f, 1.0f, 0.05f, 1.5f, 0.01f, 4.0f, 68},
424 { 0.1f, 1.0f, 0.05f, 1.5f, 0.01f, 4.0f, 68},
425 { 0.2f, 4.0f, 0.05f, 20.0f, 0.01f, 16.0f, 100},
426 { 0.1f, 1.0f, 0.05f, 2.0f, 0.01f, 4.0f, 70},
427 { 0.1f, 1.0f, 0.05f, 2.0f, 0.01f, 4.0f, 70},
428 { 0.1f, 1.1f, 0.05f, 1.5f, 0.02f, 2.5f, 61.5},
429 { 0.2f, 0.1f, 0.05f, 0.1f, 0.01f, 0.1f, 56},
430 { 0.1f, 0.0f, 0.01f, 0.0f, 0.01f, 0.0f, 0},
431 { 0.1f, 0.0f, 0.01f, 0.0f, 0.01f, 0.0f, 0},
432 { 0.1f, 2.0f, 0.05f, 12.0f, 0.01f, 10.0f, 40},
433 { 0.2f, 0.1f, 0.05f, 0.1f, 0.01f, 0.1f, 56},
434 { 0.1f, 1.0f, 0.05f, 1.5f, 0.01f, 4.0f, 68},
435 { 0.2f, 2.0f, 0.05f, 10.0f, 0.01f, 8.0f, 80},
436 { 0.1f, 2.0f, 0.05f, 8.0f, 0.01f, 6.0f, 80},
437 { 0.1f, 1.0f, 0.05f, 2.0f, 0.01f, 4.0f, 64},
438 { 0.1f, 0.5f, 0.05f, 1.0f, 0.01f, 1.0f, 64},
439 { 0.2f, 2.0f, 0.05f, 5.0f, 0.01f, 4.0f, 75},
440 { 0.2f, 2.0f, 0.05f, 12.0f, 0.01f, 10.0f, 80},
441 { 0.2f, 2.0f, 0.05f, 12.0f, 0.01f, 10.0f, 80},
442 { 0.2f, 3.0f, 0.05f, 16.0f, 0.01f, 12.0f, 80},
443 { 0.1f, 3.0f, 0.05f, 6.0f, 0.01f, 6.0f, 70},
444 { 0.2f, 3.0f, 0.05f, 12.0f, 0.01f, 10.0f, 80},
445 { 0.1f, 3.0f, 0.05f, 6.0f, 0.01f, 6.0f, 70},
446 { 0.1f, 2.0f, 0.05f, 12.0f, 0.01f, 10.0f, 40},
447 { 0.1f, 2.0f, 0.05f, 12.0f, 0.01f, 10.0f, 40},
448 { 0.1f, 0.5f, 0.05f, 1.0f, 0.01f, 1.0f, 64},
449 { 0.1f, 1.0f, 0.05f,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0f, 0.0f, 0.0f, 0.0f, 0.0f, 0}, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0},
493 { 0.1f, 1.0f, 0.05f, 2.0f, 0.01f, 4.0f, 70},
494 { 0.2f, 2.0f, 0.05f, 10.0f, 0.01f, 8.0f, 80},
495 { 0.1f, 1.0f, 0.05f, 2.0f, 0.01f, 4.0f, 70},
496 { 0.1f, 1.0f, 0.05f, 2.0f, 0.01f, 4.0f, 70},
497 {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0},
498 { 0.1f, 1.0f, 0.05f, 2.0f, 0.01f, 4.0f, 70},
499 { 0.2f, 2.0f, 0.05f, 10.0f, 0.01f, 8.0f, 80},
500 { 0.2f, 4.0f, 0.05f, 20.0f, 0.01f, 16.0f, 120},
501 { 0.1f, 1.0f, 0.05f, 1.5f, 0.01f, 4.0f, 68},
502 { 0.1f, 1.0f, 0.05f, 1.5f, 0.01f, 4.0f, 80},
503 { 0.2f, 2.0f, 0.1f, 30.0f, 0.01f, 8.0f, 80},
504 { 0.1f, 1.0f, 0.05f, 1.5f, 0.01f, 4.0f, 80},
505 { 0.1f, 1.0f, 0.05f, 1.5f, 0.01f, 4.0f, 80},
515 BiomeNeighbors Biomes;
516 for (
int z = -1; z <= 1; z++)
518 for (
int x = -1; x <= 1; x++)
520 m_BiomeGen->GenBiomes({a_ChunkCoords.
m_ChunkX + x, a_ChunkCoords.
m_ChunkZ + z}, Biomes[x + 1][z + 1]);
529 for (
int z = 0; z < 17; z += STEPZ)
531 for (
int x = 0; x < 17; x += STEPX)
536 LinearUpscale2DArrayInPlace<17, 17, STEPX, STEPZ>(Height);
564 int BiomeCounts[256];
565 memset(BiomeCounts, 0,
sizeof(BiomeCounts));
567 for (
int z = -8; z <= 8; z++)
572 int WeightZ = 9 - abs(z);
573 for (
int x = -8; x <= 8; x++)
579 int WeightX = 9 - abs(x);
580 BiomeCounts[Biome] += WeightX + WeightZ;
581 Sum += WeightX + WeightZ;
591 for (
size_t i = 0; i <
ARRAYCOUNT(BiomeCounts); i++)
593 if (BiomeCounts[i] == 0)
608 NOISE_DATATYPE oct1 = m_Noise.CubicNoise2D(BlockX * m_GenParam[i].m_HeightFreq1, BlockZ * m_GenParam[i].m_HeightFreq1) * m_GenParam[i].m_HeightAmp1;
609 NOISE_DATATYPE oct2 = m_Noise.CubicNoise2D(BlockX * m_GenParam[i].m_HeightFreq2, BlockZ * m_GenParam[i].m_HeightFreq2) * m_GenParam[i].m_HeightAmp2;
610 NOISE_DATATYPE oct3 = m_Noise.CubicNoise2D(BlockX * m_GenParam[i].m_HeightFreq3, BlockZ * m_GenParam[i].m_HeightFreq3) * m_GenParam[i].m_HeightAmp3;
611 Height += BiomeCounts[i] * (m_GenParam[i].m_BaseHeight + oct1 + oct2 + oct3);
614 return std::min(static_cast<NOISE_DATATYPE>(250), std::max(res, static_cast<NOISE_DATATYPE>(5)));
618 ASSERT(!
"cHeiGenBiomal: Biome sum failed, no known biome around");
635 static const int AVERAGING_SIZE = 4;
640 m_BiomeGen(a_BiomeGen),
644 for (
int z = 0; z <= AVERAGING_SIZE * 2; z++)
646 for (
int x = 0; x <= AVERAGING_SIZE * 2; x++)
648 m_Weights[z][x] = 1 + 2 * AVERAGING_SIZE - std::abs(x - AVERAGING_SIZE) - std::abs(z - AVERAGING_SIZE);
649 m_TotalWeight += m_Weights[z][x];
664 for (
int z = 0; z < 3; z++)
for (
int x = 0; x < 3; x++)
666 m_BiomeGen->GenBiomes({a_ChunkCoords.
m_ChunkX + x - 1, a_ChunkCoords.
m_ChunkZ + z - 1}, neighborBiomes[z][x]);
677 double min = 0, max = 0;
678 for (
int relz = 0; relz <= AVERAGING_SIZE * 2; relz++)
680 int bz = z + 16 + relz - AVERAGING_SIZE;
683 for (
int relx = 0; relx <= AVERAGING_SIZE * 2; relx++)
685 int bx = x + 16 + relx - AVERAGING_SIZE;
694 min += bmin * m_Weights[relz][relx];
695 max += bmax * m_Weights[relz][relx];
719 double h = (max + min) / 2 + noise[x + z * cChunkDef::Width] * (max - min);
740 double m_Weights[AVERAGING_SIZE * 2 + 1][AVERAGING_SIZE * 2 + 1];
751 case biBeach: a_Min = 61; a_Max = 64;
break;
761 case biDesert: a_Min = 63; a_Max = 70;
break;
763 case biDesertM: a_Min = 63; a_Max = 70;
break;
764 case biEnd: a_Min = 10; a_Max = 100;
break;
771 case biForest: a_Min = 63; a_Max = 75;
break;
778 case biJungle: a_Min = 60; a_Max = 80;
break;
782 case biJungleM: a_Min = 60; a_Max = 75;
break;
787 case biMesa: a_Min = 63; a_Max = 90;
break;
795 case biNether: a_Min = 10; a_Max = 100;
break;
796 case biOcean: a_Min = 45; a_Max = 64;
break;
797 case biPlains: a_Min = 63; a_Max = 70;
break;
798 case biRiver: a_Min = 60; a_Max = 62;
break;
801 case biSavanna: a_Min = 63; a_Max = 75;
break;
802 case biSavannaM: a_Min = 63; a_Max = 80;
break;
809 case biTaiga: a_Min = 63; a_Max = 75;
break;
811 case biTaigaM: a_Min = 63; a_Max = 80;
break;
836 if (HeightGenName.empty())
838 LOGWARN(
"[Generator] HeightGen value not set in world.ini, using \"Biomal\".");
839 HeightGenName =
"Biomal";
842 a_CacheOffByDefault =
false;
846 res = std::make_shared<cHeiGenFlat>();
847 a_CacheOffByDefault =
true;
851 res = std::make_shared<cHeiGenClassic>(a_Seed);
853 else if (
NoCaseCompare(HeightGenName,
"DistortedHeightmap") == 0)
867 res = std::make_shared<cHeiGenMinMax>(a_Seed, a_BiomeGen);
871 res = std::make_shared<cHeiGenMountains>(a_Seed);
881 res = std::make_shared<cHeiGenSteppy>(a_Seed);
891 res = std::make_shared<cHeiGenBiomal>(a_Seed, a_BiomeGen);
909 LOGWARN(
"Unknown HeightGen \"%s\", using \"Biomal\" instead.", HeightGenName.c_str());
910 a_IniFile.
SetValue(
"Generator",
"HeightGen",
"Biomal");
911 return CreateHeightGen(a_IniFile, a_BiomeGen, a_Seed, a_CacheOffByDefault);
915 res->InitializeHeightGen(a_IniFile);
std::vector< size_t > m_CacheOrder
static const size_t m_CoeffZ
The coefficient used to turn Z coords into index (x + Coeff * z).
virtual void InitializeHeightGen(cIniFile &a_IniFile) override
Initializes the generator, reading its parameters from the INI file.
virtual void InitializeHeightGen(cIniFile &a_IniFile) override
Initializes the generator, reading its parameters from the INI file.
double GetValueSetF(const AString &keyname, const AString &valuename, const double defValue=0.0)
cBiomeGenPtr m_BiomeGen
The biome generator to query for the underlying biomes.
cRidgedMultiNoise m_DitchNoise
std::shared_ptr< cTerrainHeightGen > cTerrainHeightGenPtr
The interface that is used to query terrain height from the shape generator.
size_t m_NumSubCaches
Number of sub-caches, pulled out of m_SubCaches.size() for performance reasons.
static HEIGHTTYPE GetHeight(const HeightMap &a_HeightMap, int a_X, int a_Z)
cHeiGenMultiCache(cTerrainHeightGenPtr a_HeightGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches)
cHeiGenCachePtrs m_SubCaches
The individual sub-caches.
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
unsigned char HEIGHTTYPE
The type used by the heightmap.
float GetNoise(float x, float y)
virtual void InitializeHeightGen(cIniFile &a_IniFile) override
Initializes the generator, reading its parameters from the INI file.
static void BlockToChunk(int a_X, int a_Z, int &a_ChunkX, int &a_ChunkZ)
Converts absolute block coords to chunk coords:
cChunkDef::BiomeMap BiomeNeighbors[3][3]
virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap &a_HeightMap) override
Retrieves the heightmap for the specified chunk.
virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap &a_HeightMap) override
Retrieves the heightmap for the specified chunk.
bool SetValue(const int keyID, const int valueID, const AString &value)
int NoCaseCompare(const AString &s1, const AString &s2)
Case-insensitive string comparison.
virtual HEIGHTTYPE GetHeightAt(int a_BlockX, int a_BlockZ) override
Returns the height at the specified column.
static const sGenParam m_GenParam[256]
double m_TotalWeight
Sum of all the m_Weights items.
static cTerrainHeightGenPtr CreateHeightGen(cIniFile &a_IniFile, cBiomeGenPtr a_BiomeGen, int a_Seed, bool &a_CacheOffByDefault)
Creates a cTerrainHeightGen descendant based on the INI file settings.
virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap &a_HeightMap) override
Retrieves the heightmap for the specified chunk.
cHeiGenMountains(int a_Seed)
float NOISE_DATATYPE
The datatype used by all the noise generators.
std::vector< sCacheData > m_CacheData
cHeiGenCache(cTerrainHeightGenPtr a_HeiGenToCache, size_t a_CacheSize)
virtual void InitializeHeightGen(cIniFile &a_IniFile) override
Initializes the generator, reading its parameters from the INI file.
std::shared_ptr< cProtIntGen > m_Gen
virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap &a_HeightMap) override
Retrieves the heightmap for the specified chunk.
T Clamp(T a_Value, T a_Min, T a_Max)
Clamp X to the specified range.
virtual HEIGHTTYPE GetHeightAt(int a_BlockX, int a_BlockZ) override
Returns the height at the specified column.
cTerrainHeightGenPtr m_HeiGenToCache
The terrain height generator that is being cached.
cRidgedMultiNoise m_MountainNoise
static void SetHeight(HeightMap &a_HeightMap, int a_X, int a_Z, HEIGHTTYPE a_Height)
void getBiomeMinMax(EMCSBiome a_Biome, double &a_Min, double &a_Max)
Returns the minimum and maximum heights for the given biome.
virtual void InitializeHeightGen(cIniFile &a_IniFile) override
Initializes the generator, reading its parameters from the INI file.
cHeiGenClassic(int a_Seed)
void AddOctave(NOISE_DATATYPE a_Frequency, NOISE_DATATYPE a_Amplitude)
Adds a new octave to the list of octaves that compose this noise.
virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap &a_HeightMap) override
Retrieves the heightmap for the specified chunk.
int GetValueSetI(const AString &keyname, const AString &valuename, const int defValue=0) override
cHeiGenMinMax(int a_Seed, cBiomeGenPtr a_BiomeGen)
cHeiGenSteppy(int a_Seed)
void Generate2D(NOISE_DATATYPE *a_Array, int a_SizeX, int a_SizeY, NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, NOISE_DATATYPE *a_Workspace=nullptr) const
Fills a 2D array with the values of the noise.
virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap &a_HeightMap) override
Retrieves the heightmap for the specified chunk.
virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap &a_HeightMap) override
Retrieves the heightmap for the specified chunk.
HEIGHTTYPE HeightMap[Width *Width]
The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the hig...
NOISE_DATATYPE CubicNoise2D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y) const
EMCSBiome BiomeMap[Width *Width]
The type used for any biomemap operations and storage inside Cuberite, using Cuberite biomes (need no...
virtual HEIGHTTYPE GetHeightAt(int a_BlockX, int a_BlockZ) override
Returns the height at the specified column.
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
virtual HEIGHTTYPE GetHeightAt(int a_BlockX, int a_BlockZ)
Returns the height at the specified column.
virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap &a_HeightMap) override
Retrieves the heightmap for the specified chunk.
static EMCSBiome GetBiome(const BiomeMap &a_BiomeMap, int a_X, int a_Z)
AString GetValueSet(const AString &keyname, const AString &valuename, const AString &defValue="") override
Gets the value; if not found, write the default to the repository.
std::shared_ptr< cBiomeGen > cBiomeGenPtr