10 #include "../IniFile.h"
11 #include "../LinearUpscale.h"
23 for (
size_t i = 0; i <
ARRAYCOUNT(a_BiomeMap); i++)
39 case dimNether: defaultBiome =
"Nether";
break;
40 case dimEnd: defaultBiome =
"End";
break;
41 case dimNotSet: defaultBiome =
"Swampland";
break;
47 LOGWARN(
"[Generator]::ConstantBiome value \"%s\" not recognized, using \"Plains\".", Biome.c_str());
60 m_BioGenToCache(a_BioGenToCache),
61 m_CacheSize(a_CacheSize),
96 for (
size_t j = i; j > 0; j--)
103 memcpy(a_BiomeMap,
m_CacheData[Idx].m_BiomeMap,
sizeof(a_BiomeMap));
121 memcpy(
m_CacheData[Idx].m_BiomeMap, a_BiomeMap,
sizeof(a_BiomeMap));
142 m_NumSubCaches(a_NumSubCaches),
143 m_Underlying(
std::move(a_BioGenToCache))
146 for (
size_t i = 0; i < a_NumSubCaches; i++)
158 const size_t coefficient = 3;
159 const size_t cacheIdx = (
static_cast<size_t>(a_ChunkCoords.
m_ChunkX) + coefficient *
static_cast<size_t>(a_ChunkCoords.
m_ChunkZ)) %
m_NumSubCaches;
161 m_Caches[cacheIdx]->GenBiomes(a_ChunkCoords, a_BiomeMap);
172 itr->InitializeBiomeGen(a_IniFile);
188 for (AStringVector::const_iterator itr = Split.begin(); itr != Split.end(); ++itr)
191 if (Split2.size() < 1)
196 if (Split2.size() >= 2)
200 LOGWARNING(
"Cannot decode biome count: \"%s\"; using 1.", Split2[1].c_str());
207 for (
int i = 0; i < Count; i++)
214 LOGWARNING(
"Cannot decode biome name: \"%s\"; skipping", Split2[0].c_str());
249 for (
size_t i = 0; i <
ARRAYCOUNT(Biomes); i++)
303 int AbsoluteZ = BaseZ + z;
319 int CellSize = a_IniFile.
GetValueSetI(
"Generator",
"VoronoiCellSize", 128);
320 int JitterSize = a_IniFile.
GetValueSetI(
"Generator",
"VoronoiJitterSize", CellSize);
321 int OddRowOffset = a_IniFile.
GetValueSetI(
"Generator",
"VoronoiOddRowOffset", 0);
343 for (
int x = 0; x <= 4; x++)
for (
int z = 0; z <= 4; z++)
345 Distort(BaseX + x * 4, BaseZ + z * 4, DistortX[4 * x][4 * z], DistortZ[4 * x][4 * z]);
348 LinearUpscale2DArrayInPlace<cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4>(&DistortX[0][0]);
349 LinearUpscale2DArrayInPlace<cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4>(&DistortZ[0][0]);
386 a_DistortedX = a_BlockX +
static_cast<int>(
m_CellSize * 0.5 * NoiseX);
387 a_DistortedZ = a_BlockZ +
static_cast<int>(
m_CellSize * 0.5 * NoiseZ);
398 m_Noise1(a_Seed + 1000),
399 m_Noise2(a_Seed + 2000),
400 m_Noise3(a_Seed + 3000),
401 m_Noise4(a_Seed + 4000),
402 m_Noise5(a_Seed + 5000),
403 m_Noise6(a_Seed + 6000),
405 m_OceanCellSize(384),
406 m_MushroomIslandSize(64),
407 m_RiverCellSize(384),
408 m_RiverWidthThreshold(0.125),
409 m_LandBiomesSize(1024)
451 for (
int x = 0; x <= 4; x++)
for (
int z = 0; z <= 4; z++)
453 Distort(BaseX + x * 4, BaseZ + z * 4, DistortX[4 * x][4 * z], DistortZ[4 * x][4 * z], DistortSize);
455 LinearUpscale2DArrayInPlace<cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4>(&DistortX[0][0]);
456 LinearUpscale2DArrayInPlace<cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4>(&DistortZ[0][0]);
460 const int NEIGHBORHOOD_SIZE = 4;
463 int SeedX[2 * NEIGHBORHOOD_SIZE + 1][2 * NEIGHBORHOOD_SIZE + 1];
464 int SeedZ[2 * NEIGHBORHOOD_SIZE + 1][2 * NEIGHBORHOOD_SIZE + 1];
465 EMCSBiome SeedV[2 * NEIGHBORHOOD_SIZE + 1][2 * NEIGHBORHOOD_SIZE + 1];
466 for (
int xc = 0; xc < 2 * NEIGHBORHOOD_SIZE + 1; xc++)
468 int RealCellX = xc + CellX - NEIGHBORHOOD_SIZE;
470 for (
int zc = 0; zc < 2 * NEIGHBORHOOD_SIZE + 1; zc++)
472 int RealCellZ = zc + CellZ - NEIGHBORHOOD_SIZE;
476 SeedX[xc][zc] = CellBlockX + OffsetX;
477 SeedZ[xc][zc] = CellBlockZ + OffsetZ;
482 for (
int xc = 1; xc < 2 * NEIGHBORHOOD_SIZE; xc++)
for (
int zc = 1; zc < 2 * NEIGHBORHOOD_SIZE; zc++)
486 (SeedV[xc - 1][zc] ==
biOcean) &&
487 (SeedV[xc + 1][zc] ==
biOcean) &&
488 (SeedV[xc ][zc - 1] ==
biOcean) &&
489 (SeedV[xc ][zc + 1] ==
biOcean) &&
490 (SeedV[xc - 1][zc - 1] ==
biOcean) &&
491 (SeedV[xc + 1][zc - 1] ==
biOcean) &&
492 (SeedV[xc - 1][zc + 1] ==
biOcean) &&
493 (SeedV[xc + 1][zc + 1] ==
biOcean)
507 int AbsoluteZ = DistortZ[x][z];
508 int AbsoluteX = DistortX[x][z];
512 for (
int xs = 1; xs < 2 * NEIGHBORHOOD_SIZE; xs++)
for (
int zs = 1; zs < 2 * NEIGHBORHOOD_SIZE; zs++)
514 int Dist = (SeedX[xs][zs] - AbsoluteX) * (SeedX[xs][zs] - AbsoluteX) + (SeedZ[xs][zs] - AbsoluteZ) * (SeedZ[xs][zs] - AbsoluteZ);
520 Biome = SeedV[xs][zs];
524 if (Dist > MushroomOceanThreshold)
528 else if (Dist > MushroomShoreThreshold)
591 double NoiseX =
m_Noise3.
CubicNoise2D(
static_cast<float>(a_BlockX / a_CellSize),
static_cast<float>(a_BlockZ / a_CellSize));
592 NoiseX += 0.5 *
m_Noise2.
CubicNoise2D(2 *
static_cast<float>(a_BlockX / a_CellSize), 2 *
static_cast<float>(a_BlockZ / a_CellSize));
593 NoiseX += 0.1 *
m_Noise1.
CubicNoise2D(16 *
static_cast<float>(a_BlockX / a_CellSize), 16 *
static_cast<float>(a_BlockZ / a_CellSize));
594 double NoiseZ =
m_Noise6.
CubicNoise2D(
static_cast<float>(a_BlockX / a_CellSize),
static_cast<float>(a_BlockZ / a_CellSize));
595 NoiseZ += 0.5 *
m_Noise5.
CubicNoise2D(2 *
static_cast<float>(a_BlockX / a_CellSize), 2 *
static_cast<float>(a_BlockZ / a_CellSize));
596 NoiseZ += 0.1 *
m_Noise4.
CubicNoise2D(16 *
static_cast<float>(a_BlockX / a_CellSize), 16 *
static_cast<float>(a_BlockZ / a_CellSize));
598 a_DistortedX = a_BlockX +
static_cast<int>(a_CellSize * 0.5 * NoiseX);
599 a_DistortedZ = a_BlockZ +
static_cast<int>(a_CellSize * 0.5 * NoiseZ);
611 for (
int z = 0; z < 17; z += 8)
614 for (
int x = 0; x < 17; x += 8)
621 TemperatureMap[x + 17 * z] = NoiseT;
626 HumidityMap[x + 17 * z] = NoiseH;
629 LinearUpscale2DArrayInPlace<17, 17, 8, 8>(TemperatureMap);
630 LinearUpscale2DArrayInPlace<17, 17, 8, 8>(HumidityMap);
633 for (
size_t idx = 0; idx <
ARRAYCOUNT(a_TemperatureMap); idx++)
635 a_TemperatureMap[idx] =
Clamp(
static_cast<int>(128 + TemperatureMap[idx] * 128), 0, 255);
636 a_HumidityMap[idx] =
Clamp(
static_cast<int>(128 + HumidityMap[idx] * 128), 0, 255);
649 biTundra,
biTundra,
biTundra,
biTundra,
biPlains,
biPlains,
biPlains,
biPlains,
biPlains,
biPlains,
biDesert,
biDesert,
biDesert,
biDesert,
biDesert,
biDesert,
650 biTundra,
biTundra,
biTundra,
biTundra,
biPlains,
biPlains,
biPlains,
biPlains,
biPlains,
biPlains,
biDesert,
biDesert,
biDesert,
biDesert,
biDesert,
biDesert,
651 biTundra,
biTundra,
biTundra,
biTundra,
biPlains,
biExtremeHills,
biPlains,
biPlains,
biPlains,
biPlains,
biDesert,
biDesert,
biDesertHills,
biDesertHills,
biDesert,
biDesert,
652 biTundra,
biTundra,
biTundra,
biTundra,
biExtremeHills,
biExtremeHills,
biPlains,
biPlains,
biPlains,
biPlains,
biDesert,
biDesert,
biDesertHills,
biDesertHills,
biDesert,
biDesert,
653 biTundra,
biTundra,
biIceMountains,
biIceMountains,
biExtremeHills,
biExtremeHills,
biPlains,
biPlains,
biPlains,
biPlains,
biForestHills,
biForestHills,
biExtremeHills,
biExtremeHills,
biDesertHills,
biDesert,
654 biTundra,
biTundra,
biIceMountains,
biIceMountains,
biExtremeHills,
biExtremeHills,
biPlains,
biPlains,
biPlains,
biPlains,
biForestHills,
biForestHills,
biExtremeHills,
biExtremeHills,
biDesertHills,
biDesert,
655 biTundra,
biTundra,
biIceMountains,
biIceMountains,
biForestHills,
biForestHills,
biForest,
biForest,
biForest,
biForest,
biForest,
biForestHills,
biExtremeHills,
biExtremeHills,
biPlains,
biPlains,
656 biTundra,
biTundra,
biIceMountains,
biIceMountains,
biForestHills,
biForestHills,
biForest,
biForest,
biForest,
biForest,
biForest,
biForestHills,
biExtremeHills,
biExtremeHills,
biPlains,
biPlains,
657 biTundra,
biTundra,
biTaiga,
biTaiga,
biForest,
biForest,
biForest,
biForest,
biForest,
biForest,
biForest,
biForestHills,
biExtremeHills,
biExtremeHills,
biPlains,
biPlains,
658 biTundra,
biTundra,
biTaiga,
biTaiga,
biForest,
biForest,
biForest,
biForest,
biForest,
biForest,
biForest,
biForestHills,
biExtremeHills,
biExtremeHills,
biPlains,
biPlains,
659 biTaiga,
biTaiga,
biTaiga,
biIceMountains,
biForestHills,
biForestHills,
biForest,
biForest,
biForest,
biForest,
biJungle,
biJungle,
biSwampland,
biSwampland,
biSwampland,
biSwampland,
660 biTaiga,
biTaiga,
biIceMountains,
biIceMountains,
biExtremeHills,
biForestHills,
biForest,
biForest,
biForest,
biForest,
biJungle,
biJungle,
biSwampland,
biSwampland,
biSwampland,
biSwampland,
661 biTaiga,
biTaiga,
biIceMountains,
biIceMountains,
biExtremeHills,
biJungleHills,
biJungle,
biJungle,
biJungle,
biJungle,
biJungle,
biJungle,
biSwampland,
biSwampland,
biSwampland,
biSwampland,
662 biTaiga,
biTaiga,
biTaiga,
biIceMountains,
biJungleHills,
biJungleHills,
biJungle,
biJungle,
biJungle,
biJungle,
biJungle,
biJungle,
biSwampland,
biSwampland,
biSwampland,
biSwampland,
663 biTaiga,
biTaiga,
biTaiga,
biTaiga,
biJungle,
biJungle,
biJungle,
biJungle,
biJungle,
biJungle,
biJungle,
biJungle,
biSwampland,
biSwampland,
biSwampland,
biSwampland,
664 biTaiga,
biTaiga,
biTaiga,
biTaiga,
biJungle,
biJungle,
biJungle,
biJungle,
biJungle,
biJungle,
biJungle,
biJungle,
biSwampland,
biSwampland,
biSwampland,
biSwampland,
677 int Temperature = a_TemperatureMap[idx] / 16;
678 int Humidity = a_HumidityMap[idx] / 16;
695 if (a_TemperatureMap[idx] > 4 * 16)
719 m_VoronoiLarge(a_Seed + 1000),
720 m_VoronoiSmall(a_Seed + 2000),
721 m_Noise1(a_Seed + 5001),
722 m_Noise2(a_Seed + 5002),
723 m_Noise3(a_Seed + 5003),
724 m_Noise4(a_Seed + 5004),
725 m_Noise5(a_Seed + 5005),
726 m_Noise6(a_Seed + 5006),
754 for (
int x = 0; x <= 4; x++)
for (
int z = 0; z <= 4; z++)
756 float BlockX =
static_cast<float>(BaseX + x * 4);
757 float BlockZ =
static_cast<float>(BaseZ + z * 4);
765 DistortX[4 * x][4 * z] =
static_cast<int>(BlockX + NoiseX);
766 DistortZ[4 * x][4 * z] =
static_cast<int>(BlockZ + NoiseZ);
769 LinearUpscale2DArrayInPlace<cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4>(&DistortX[0][0]);
770 LinearUpscale2DArrayInPlace<cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4>(&DistortZ[0][0]);
777 int SeedX, SeedZ, MinDist2;
779 size_t BiomeIdx =
static_cast<size_t>(
m_VoronoiSmall.
GetValueAt(DistortX[x][z], DistortZ[x][z], SeedX, SeedZ, MinDist2) / 11);
780 int MinDist1 = (DistortX[x][z] - SeedX) * (DistortX[x][z] - SeedX) + (DistortZ[x][z] - SeedZ) * (DistortZ[x][z] - SeedZ);
799 static BiomeLevels bgOceanBlocks[] =
813 static BiomeLevels bgFrozenBlocks[] =
826 static BiomeLevels bgTemperateBlocks[] =
842 static BiomeLevels bgWarmBlocks[] =
851 static BiomeLevels bgMesaBlocks[] =
861 static BiomeLevels bgConifersBlocks[] =
869 static BiomeLevels bgDenseTreesBlocks[] =
877 BiomeLevels * Biomes;
881 { bgOceanBlocks,
ARRAYCOUNT(bgOceanBlocks), },
882 { bgOceanBlocks,
ARRAYCOUNT(bgOceanBlocks), },
883 { bgFrozenBlocks,
ARRAYCOUNT(bgFrozenBlocks), },
884 { bgFrozenBlocks,
ARRAYCOUNT(bgFrozenBlocks), },
885 { bgTemperateBlocks,
ARRAYCOUNT(bgTemperateBlocks), },
886 { bgTemperateBlocks,
ARRAYCOUNT(bgTemperateBlocks), },
887 { bgConifersBlocks,
ARRAYCOUNT(bgConifersBlocks), },
888 { bgConifersBlocks,
ARRAYCOUNT(bgConifersBlocks), },
892 { bgDenseTreesBlocks,
ARRAYCOUNT(bgDenseTreesBlocks), },
894 size_t Group =
static_cast<size_t>(a_BiomeGroup) %
ARRAYCOUNT(BiomeGroups);
895 size_t Index = a_BiomeIdx % BiomeGroups[Group].Count;
896 return (a_DistLevel > 0) ? BiomeGroups[Group].Biomes[Index].InnerBiome : BiomeGroups[Group].Biomes[Index].OuterBiome;
907 m_FreqX1 =
static_cast<float>(a_IniFile.
GetValueSetF(
"Generator",
"TwoLevelDistortXOctave1Freq", 0.01));
908 m_AmpX1 =
static_cast<float>(a_IniFile.
GetValueSetF(
"Generator",
"TwoLevelDistortXOctave1Amp", 80));
909 m_FreqX2 =
static_cast<float>(a_IniFile.
GetValueSetF(
"Generator",
"TwoLevelDistortXOctave2Freq", 0.05));
910 m_AmpX2 =
static_cast<float>(a_IniFile.
GetValueSetF(
"Generator",
"TwoLevelDistortXOctave2Amp", 20));
911 m_FreqX3 =
static_cast<float>(a_IniFile.
GetValueSetF(
"Generator",
"TwoLevelDistortXOctave3Freq", 0.1));
912 m_AmpX3 =
static_cast<float>(a_IniFile.
GetValueSetF(
"Generator",
"TwoLevelDistortXOctave3Amp", 8));
913 m_FreqZ1 =
static_cast<float>(a_IniFile.
GetValueSetF(
"Generator",
"TwoLevelDistortZOctave1Freq", 0.01));
914 m_AmpZ1 =
static_cast<float>(a_IniFile.
GetValueSetF(
"Generator",
"TwoLevelDistortZOctave1Amp", 80));
915 m_FreqZ2 =
static_cast<float>(a_IniFile.
GetValueSetF(
"Generator",
"TwoLevelDistortZOctave2Freq", 0.05));
916 m_AmpZ2 =
static_cast<float>(a_IniFile.
GetValueSetF(
"Generator",
"TwoLevelDistortZOctave2Amp", 20));
917 m_FreqZ3 =
static_cast<float>(a_IniFile.
GetValueSetF(
"Generator",
"TwoLevelDistortZOctave3Freq", 0.1));
918 m_AmpZ3 =
static_cast<float>(a_IniFile.
GetValueSetF(
"Generator",
"TwoLevelDistortZOctave3Amp", 8));
936 std::make_shared<cIntGenChoice<2, 7>>(a_Seed + 12)
938 | MakeIntGen<cIntGenSmooth<8>>(a_Seed + 6)
940 | MakeIntGen<cIntGenZoom <8>>(a_Seed + 10)
942 | MakeIntGen<cIntGenZoom <8>>(a_Seed + 9)
944 | MakeIntGen<cIntGenZoom <8>>(a_Seed + 8)
946 | MakeIntGen<cIntGenZoom <9>>(a_Seed + 4)
948 | MakeIntGen<cIntGenZoom <10>>(a_Seed + 2)
952 std::make_shared<cIntGenZoom <8>>(a_Seed,
953 std::make_shared<cIntGenLandOcean<6>>(a_Seed, 20
957 std::make_shared<cIntGenZoom <8>>(a_Seed + 1,
958 std::make_shared<cIntGenZoom <6>>(a_Seed + 2,
959 std::make_shared<cIntGenZoom <5>>(a_Seed + 1,
960 std::make_shared<cIntGenZoom <4>>(a_Seed + 2,
961 std::make_shared<cIntGenLandOcean<4>>(a_Seed + 1, 10
965 std::make_shared<cIntGenSmooth <8>> (a_Seed + 1,
966 std::make_shared<cIntGenZoom <10>>(a_Seed + 15,
967 std::make_shared<cIntGenSmooth <7>> (a_Seed + 1,
968 std::make_shared<cIntGenZoom <9>> (a_Seed + 16,
969 std::make_shared<cIntGenBeaches <6>> (
970 std::make_shared<cIntGenZoom <8>> (a_Seed + 1,
971 std::make_shared<cIntGenAddIslands <6>> (a_Seed + 2004, 10,
972 std::make_shared<cIntGenAddToOcean <6>> (a_Seed + 10, 500,
biDeepOcean,
974 std::make_shared<cIntGenMBiomes <8>> (a_Seed + 5, alteration2,
975 std::make_shared<cIntGenAlternateBiomes<8>> (a_Seed + 1, alteration,
976 std::make_shared<cIntGenBiomeEdges <8>> (a_Seed + 3,
977 std::make_shared<cIntGenZoom <10>>(a_Seed + 2,
978 std::make_shared<cIntGenZoom <7>> (a_Seed + 4,
980 std::make_shared<cIntGenZoom <5>> (a_Seed + 8,
981 std::make_shared<cIntGenAddToOcean <4>> (a_Seed + 10, 300,
biDeepOcean,
983 std::make_shared<cIntGenBiomes <8>> (a_Seed + 3000,
984 std::make_shared<cIntGenAddIslands <8>> (a_Seed + 2000, 200,
985 std::make_shared<cIntGenZoom <8>> (a_Seed + 5,
986 std::make_shared<cIntGenRareBiomeGroups<6>> (a_Seed + 5, 50,
987 std::make_shared<cIntGenBiomeGroupEdges<6>> (
988 std::make_shared<cIntGenAddIslands <8>> (a_Seed + 2000, 200,
989 std::make_shared<cIntGenZoom <8>> (a_Seed + 7,
990 std::make_shared<cIntGenSetRandomly <6>> (a_Seed + 8, 50,
bgOcean,
991 std::make_shared<cIntGenReplaceRandomly<6>> (a_Seed + 101,
bgIce,
bgTemperate, 150,
992 std::make_shared<cIntGenAddIslands <6>> (a_Seed + 2000, 200,
993 std::make_shared<cIntGenSetRandomly <6>> (a_Seed + 9, 50,
bgOcean,
994 std::make_shared<cIntGenLandOcean <5>> (a_Seed + 100, 30)
996 )))))))))))))))))))))))))))));
999 std::make_shared<cIntGenSmooth <16>>(a_Seed,
1000 std::make_shared<cIntGenZoom <18>>(a_Seed,
1001 std::make_shared<cIntGenSmooth <11>>(a_Seed,
1002 std::make_shared<cIntGenZoom <13>>(a_Seed,
1003 std::make_shared<cIntGenMixRivers<8>> (
1004 FinalBiomes, FinalRivers
1039 std::make_shared<cProtIntGenSmooth>(a_Seed + 1,
1040 std::make_shared<cProtIntGenZoom >(a_Seed + 2,
1041 std::make_shared<cProtIntGenRiver >(a_Seed + 3,
1042 std::make_shared<cProtIntGenZoom >(a_Seed + 4,
1043 std::make_shared<cProtIntGenSmooth>(a_Seed + 5,
1044 std::make_shared<cProtIntGenZoom >(a_Seed + 8,
1045 std::make_shared<cProtIntGenSmooth>(a_Seed + 5,
1046 std::make_shared<cProtIntGenZoom >(a_Seed + 9,
1047 std::make_shared<cProtIntGenSmooth>(a_Seed + 5,
1048 std::make_shared<cProtIntGenZoom >(a_Seed + 10,
1049 std::make_shared<cProtIntGenSmooth>(a_Seed + 5,
1050 std::make_shared<cProtIntGenSmooth>(a_Seed + 6,
1051 std::make_shared<cProtIntGenZoom >(a_Seed + 11,
1052 std::make_shared<cProtIntGenChoice>(a_Seed + 12, 2
1056 std::make_shared<cProtIntGenZoom >(a_Seed,
1057 std::make_shared<cProtIntGenLandOcean>(a_Seed, 20
1061 std::make_shared<cProtIntGenZoom >(a_Seed + 1,
1062 std::make_shared<cProtIntGenZoom >(a_Seed + 2,
1063 std::make_shared<cProtIntGenZoom >(a_Seed + 1,
1064 std::make_shared<cProtIntGenZoom >(a_Seed + 2,
1065 std::make_shared<cProtIntGenLandOcean>(a_Seed + 1, 10
1069 std::make_shared<cProtIntGenSmooth >(a_Seed + 1,
1070 std::make_shared<cProtIntGenZoom >(a_Seed + 15,
1071 std::make_shared<cProtIntGenSmooth >(a_Seed + 1,
1072 std::make_shared<cProtIntGenZoom >(a_Seed + 16,
1073 std::make_shared<cProtIntGenBeaches >(
1074 std::make_shared<cProtIntGenZoom >(a_Seed + 1,
1075 std::make_shared<cProtIntGenAddIslands >(a_Seed + 2004, 10,
1076 std::make_shared<cProtIntGenAddToOcean >(a_Seed + 10, 500,
biDeepOcean,
1078 std::make_shared<cProtIntGenMBiomes >(a_Seed + 5, alteration2,
1079 std::make_shared<cProtIntGenAlternateBiomes>(a_Seed + 1, alteration,
1080 std::make_shared<cProtIntGenBiomeEdges >(a_Seed + 3,
1081 std::make_shared<cProtIntGenZoom >(a_Seed + 2,
1082 std::make_shared<cProtIntGenZoom >(a_Seed + 4,
1084 std::make_shared<cProtIntGenZoom >(a_Seed + 8,
1085 std::make_shared<cProtIntGenAddToOcean >(a_Seed + 10, 300,
biDeepOcean,
1087 std::make_shared<cProtIntGenBiomes >(a_Seed + 3000,
1088 std::make_shared<cProtIntGenAddIslands >(a_Seed + 2000, 200,
1089 std::make_shared<cProtIntGenZoom >(a_Seed + 5,
1090 std::make_shared<cProtIntGenRareBiomeGroups>(a_Seed + 5, 50,
1091 std::make_shared<cProtIntGenBiomeGroupEdges>(
1092 std::make_shared<cProtIntGenAddIslands >(a_Seed + 2000, 200,
1093 std::make_shared<cProtIntGenZoom >(a_Seed + 7,
1094 std::make_shared<cProtIntGenSetRandomly >(a_Seed + 8, 50,
bgOcean,
1095 std::make_shared<cProtIntGenReplaceRandomly>(a_Seed + 101,
bgIce,
bgTemperate, 150,
1096 std::make_shared<cProtIntGenAddIslands >(a_Seed + 2000, 200,
1097 std::make_shared<cProtIntGenSetRandomly >(a_Seed + 9, 50,
bgOcean,
1098 std::make_shared<cProtIntGenZoom >(a_Seed + 10,
1099 std::make_shared<cProtIntGenLandOcean >(a_Seed + 100, 30
1100 )))))))))))))))))))))))))))))));
1103 std::make_shared<cProtIntGenSmooth >(a_Seed,
1104 std::make_shared<cProtIntGenZoom >(a_Seed,
1105 std::make_shared<cProtIntGenSmooth >(a_Seed,
1106 std::make_shared<cProtIntGenZoom >(a_Seed,
1107 std::make_shared<cProtIntGenMixRivers>(
1108 FinalBiomes, FinalRivers
1139 if (BiomeGenName.empty())
1141 LOGWARN(
"[Generator] BiomeGen value not set in world.ini, using \"Grown\".");
1142 BiomeGenName =
"Grown";
1145 std::unique_ptr<cBiomeGen> res;
1146 a_CacheOffByDefault =
false;
1149 res = std::make_unique<cBioGenConstant>();
1150 a_CacheOffByDefault =
true;
1154 res = std::make_unique<cBioGenCheckerboard>();
1155 a_CacheOffByDefault =
true;
1159 res = std::make_unique<cBioGenVoronoi>(a_Seed);
1161 else if (
NoCaseCompare(BiomeGenName,
"distortedvoronoi") == 0)
1163 res = std::make_unique<cBioGenDistortedVoronoi>(a_Seed);
1167 res = std::make_unique<cBioGenTwoLevel>(a_Seed);
1171 res = std::make_unique<cBioGenMultiStepMap>(a_Seed);
1175 res = std::make_unique<cBioGenProtGrown>(a_Seed);
1181 LOGWARNING(
"Unknown BiomeGen \"%s\", using \"Grown\" instead.", BiomeGenName.c_str());
1183 res = std::make_unique<cBioGenGrown>(a_Seed);
1185 res->InitializeBiomeGen(a_IniFile);
1202 class cBioGenPerfTest
1207 std::cout <<
"BioGen performance tests commencing, please wait..." << std::endl;
1208 TestGen(
"MultiStepMap", std::make_unique<cBioGenMultiStepMap>(1).get());
1209 TestGen(
"Grown", std::make_unique<cBioGenGrown>(1).get());
1210 TestGen(
"GrownProt", std::make_unique<cBioGenProtGrown>(1).get());
1211 std::cout <<
"BioGen performance tests complete." << std::endl;
1222 auto start = std::chrono::system_clock::now();
1223 for (
int z = 0; z < 100; z++)
1225 for (
int x = 0; x < 100; x++)
1231 auto dur = std::chrono::system_clock::now() - start;
1232 double milliseconds =
static_cast<double>((std::chrono::duration_cast<std::chrono::milliseconds>(dur)).count());
1234 std::cout << a_GenName <<
": " << 1000.0 * 100.0 * 100.0 / milliseconds <<
" chunks per second" << std::endl;
EMCSBiome StringToBiome(const AString &a_BiomeString)
Translates a biome string to biome enum.
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
eDimension StringToDimension(const AString &a_DimensionString)
Translates a dimension string to dimension enum.
cIntGenFactory< Gen, Args... > MakeIntGen(Args &&... a_Args)
const int bgOcean
Constants representing the biome group designators.
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
T Clamp(T a_Value, T a_Min, T a_Max)
Clamp X to the specified range.
void LOGWARNING(std::string_view a_Format, const Args &... args)
AStringVector StringSplitAndTrim(const AString &str, const AString &delim)
Split the string at any of the listed delimiters and trim each value.
AStringVector StringSplit(const AString &str, const AString &delim)
Split the string at any of the listed delimiters.
int NoCaseCompare(const AString &s1, const AString &s2)
Case-insensitive string comparison.
std::vector< AString > AStringVector
bool StringToInteger(const AString &a_str, T &a_Num)
Parses any integer type.
Wraps the chunk coords into a single structure.
static EMCSBiome GetBiome(const BiomeMap &a_BiomeMap, int a_X, int a_Z)
static void SetBiome(BiomeMap &a_BiomeMap, int a_X, int a_Z, EMCSBiome a_Biome)
EMCSBiome BiomeMap[Width *Width]
The type used for any biomemap operations and storage inside Cuberite, using Cuberite biomes (need no...
virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_Biomes) override
Generates biomes for the given chunk.
std::shared_ptr< cIntGen< 16, 16 > > m_Gen
virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_Biomes) override
Generates biomes for the given chunk.
std::shared_ptr< cProtIntGen > m_Gen
cBioGenProtGrown(int a_Seed)
virtual void InitializeBiomeGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap) override
Generates biomes for the given chunk.
std::vector< size_t > m_CacheOrder
virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap) override
Generates biomes for the given chunk.
virtual void InitializeBiomeGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
std::vector< sCacheData > m_CacheData
cBiomeGen & m_BioGenToCache
cBioGenCache(cBiomeGen &a_BioGenToCache, size_t a_CacheSize)
std::vector< std::unique_ptr< cBioGenCache > > m_Caches
Individual sub-caches.
std::unique_ptr< cBiomeGen > m_Underlying
The underlying biome generator.
size_t m_NumSubCaches
Number of sub-caches.
cBioGenMulticache(std::unique_ptr< cBiomeGen > a_BioGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches)
virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap) override
Generates biomes for the given chunk.
virtual void InitializeBiomeGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
void InitializeBiomes(const AString &a_Biomes)
Parses the INI file setting string into m_Biomes.
virtual void InitializeBiomeGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap) override
Generates biomes for the given chunk.
virtual void InitializeBiomeGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap) override
Generates biomes for the given chunk.
virtual void InitializeBiomeGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
void Distort(int a_BlockX, int a_BlockZ, int &a_DistortedX, int &a_DistortedZ)
Distorts the coords using a Perlin-like noise.
cVoronoiMap m_Voronoi
The underlying Voronoi map of the biomes.
virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap) override
Generates biomes for the given chunk.
int m_CellSize
Size of the Voronoi cells, also used for distortion amplitude.
cNoise m_Noise
Noise used for the distortion.
void BuildTemperatureHumidityMaps(cChunkCoords a_ChunkCoords, IntMap &a_TemperatureMap, IntMap &a_HumidityMap)
Builds two Perlin-noise maps, one for temperature, the other for humidity.
void DecideOceanLandMushroom(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap)
Step 1: Decides between ocean, land and mushroom, using a DistVoronoi with special conditions and pos...
cBioGenMultiStepMap(int a_Seed)
void Distort(int a_BlockX, int a_BlockZ, int &a_DistortedX, int &a_DistortedZ, int a_CellSize)
Distorts the coords using a Perlin-like noise, with a specified cell-size.
double m_RiverWidthThreshold
virtual void InitializeBiomeGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
void FreezeWaterBiomes(cChunkDef::BiomeMap &a_BiomeMap, const IntMap &a_TemperatureMap)
Flips biOcean and biRiver into biFrozenOcean and biFrozenRiver if the temperature is too low.
void DecideLandBiomes(cChunkDef::BiomeMap &a_BiomeMap, const IntMap &a_TemperatureMap, const IntMap &a_HumidityMap)
Flips all remaining "-1" biomes into land biomes using the two maps.
virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap) override
Generates biomes for the given chunk.
void AddRivers(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap)
Step 2: Add rivers to the land Flips some "-1" biomes into biRiver.
void ApplyTemperatureHumidity(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap)
Step 3: Decide land biomes using a temperature / humidity map; freeze ocean / river in low temperatur...
cBioGenTwoLevel(int a_Seed)
cVoronoiMap m_VoronoiSmall
The Voronoi map that decides biomes inside individual biome groups.
EMCSBiome SelectBiome(int a_BiomeGroup, size_t a_BiomeIdx, int a_DistLevel)
Selects biome from the specified biome group, based on the specified index.
virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap) override
Generates biomes for the given chunk.
cVoronoiMap m_VoronoiLarge
The Voronoi map that decides the groups of biomes.
virtual void InitializeBiomeGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
The interface that a biome generator must implement A biome generator takes chunk coords on input and...
virtual void InitializeBiomeGen(cIniFile &a_IniFile)
Reads parameters from the ini file, prepares generator for use.
static std::unique_ptr< cBiomeGen > CreateBiomeGen(cIniFile &a_IniFile, int a_Seed, bool &a_CacheOffByDefault)
Creates the correct BiomeGen descendant based on the ini file settings.
virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap)=0
Generates biomes for the given chunk.
int[SizeX *SizeZ] Values
Holds the array of values generated by this class (descendant).
Zooms the underlying value array to twice the size.
Smoothes out some artifacts generated by the zooming - mostly single-pixel values.
Generates a river based on the underlying data.
AString GetValue(const AString &keyname, const AString &valuename, const AString &defValue="") const override
Get the value at the specified key and value, returns defValue on failure.
int GetValueSetI(const AString &keyname, const AString &valuename, const int defValue=0) override
AString GetValueSet(const AString &keyname, const AString &valuename, const AString &defValue="") override
Gets the value; if not found, write the default to the repository.
double GetValueSetF(const AString &keyname, const AString &valuename, const double defValue=0.0)
NOISE_DATATYPE CubicNoise2D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y) const
NOISE_DATATYPE CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOISE_DATATYPE a_Z) const
int IntNoise3DInt(int a_X, int a_Y, int a_Z) const
void SetCellSize(int a_CellSize)
Sets both the cell size and jitter size used for generating the Voronoi seeds.
void SetJitterSize(int a_JitterSize)
Sets the jitter size.
void SetOddRowOffset(int a_OddRowOffset)
Sets the offset that is added to each odd row of cells.
int GetValueAt(int a_X, int a_Y)
Returns the value in the cell into which the specified point lies.