Lakes: added a limiter, better height distribution
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1287 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
b4697ab9db
commit
d43026ddc2
@ -335,11 +335,13 @@ void cComposableGenerator::InitStructureGens(cIniFile & a_IniFile)
|
|||||||
}
|
}
|
||||||
else if (NoCaseCompare(*itr, "waterlakes") == 0)
|
else if (NoCaseCompare(*itr, "waterlakes") == 0)
|
||||||
{
|
{
|
||||||
m_StructureGens.push_back(new cStructGenLakes(Seed * 3 + 652, E_BLOCK_STATIONARY_WATER, *m_HeightGen));
|
int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25);
|
||||||
|
m_StructureGens.push_back(new cStructGenLakes(Seed * 3 + 652, E_BLOCK_STATIONARY_WATER, *m_HeightGen, Probability));
|
||||||
}
|
}
|
||||||
else if (NoCaseCompare(*itr, "lavalakes") == 0)
|
else if (NoCaseCompare(*itr, "lavalakes") == 0)
|
||||||
{
|
{
|
||||||
m_StructureGens.push_back(new cStructGenLakes(Seed * 5 + 16873, E_BLOCK_STATIONARY_LAVA, *m_HeightGen));
|
int Probability = a_IniFile.GetValueSetI("Generator", "LavaLakesProbability", 10);
|
||||||
|
m_StructureGens.push_back(new cStructGenLakes(Seed * 5 + 16873, E_BLOCK_STATIONARY_LAVA, *m_HeightGen, Probability));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -400,6 +400,11 @@ void cStructGenLakes::GenStructures(cChunkDesc & a_ChunkDesc)
|
|||||||
|
|
||||||
for (int z = -1; z < 2; z++) for (int x = -1; x < 2; x++)
|
for (int z = -1; z < 2; z++) for (int x = -1; x < 2; x++)
|
||||||
{
|
{
|
||||||
|
if (((m_Noise.IntNoise2DInt(ChunkX + x, ChunkZ + z) / 17) % 100) > m_Probability)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
cBlockArea Lake;
|
cBlockArea Lake;
|
||||||
CreateLakeImage(ChunkX + x, ChunkZ + z, Lake);
|
CreateLakeImage(ChunkX + x, ChunkZ + z, Lake);
|
||||||
|
|
||||||
@ -420,19 +425,20 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a
|
|||||||
a_Lake.Create(16, 8, 16);
|
a_Lake.Create(16, 8, 16);
|
||||||
a_Lake.Fill(cBlockArea::baTypes, E_BLOCK_SPONGE); // Sponge is the NOP blocktype for lake merging strategy
|
a_Lake.Fill(cBlockArea::baTypes, E_BLOCK_SPONGE); // Sponge is the NOP blocktype for lake merging strategy
|
||||||
|
|
||||||
// Find the maximum height in this chunk:
|
// Find the minimum height in this chunk:
|
||||||
cChunkDef::HeightMap HeightMap;
|
cChunkDef::HeightMap HeightMap;
|
||||||
m_HeiGen.GenHeightMap(a_ChunkX, a_ChunkZ, HeightMap);
|
m_HeiGen.GenHeightMap(a_ChunkX, a_ChunkZ, HeightMap);
|
||||||
HEIGHTTYPE MaxHeight = HeightMap[0];
|
HEIGHTTYPE MinHeight = HeightMap[0];
|
||||||
for (int i = 1; i < ARRAYCOUNT(HeightMap); i++)
|
for (int i = 1; i < ARRAYCOUNT(HeightMap); i++)
|
||||||
{
|
{
|
||||||
if (HeightMap[i] > MaxHeight)
|
if (HeightMap[i] < MinHeight)
|
||||||
{
|
{
|
||||||
MaxHeight = HeightMap[i];
|
MinHeight = HeightMap[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a random position in the chunk by using a random 16 block XZ offset and random height up to chunk's max height
|
// Make a random position in the chunk by using a random 16 block XZ offset and random height up to chunk's max height minus 6
|
||||||
|
MinHeight = std::max(MinHeight - 6, 2);
|
||||||
int Rnd = m_Noise.IntNoise3DInt(a_ChunkX, 128, a_ChunkZ) / 11;
|
int Rnd = m_Noise.IntNoise3DInt(a_ChunkX, 128, a_ChunkZ) / 11;
|
||||||
// Random offset [-8 .. 8], with higher probability around 0; add up four three-bit-wide randoms [0 .. 28], divide and subtract to get range
|
// Random offset [-8 .. 8], with higher probability around 0; add up four three-bit-wide randoms [0 .. 28], divide and subtract to get range
|
||||||
int OffsetX = 4 * ((Rnd & 0x07) + ((Rnd & 0x38) >> 3) + ((Rnd & 0x1c0) >> 6) + ((Rnd & 0xe00) >> 9)) / 7 - 8;
|
int OffsetX = 4 * ((Rnd & 0x07) + ((Rnd & 0x38) >> 3) + ((Rnd & 0x1c0) >> 6) + ((Rnd & 0xe00) >> 9)) / 7 - 8;
|
||||||
@ -440,8 +446,9 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a
|
|||||||
// Random offset [-8 .. 8], with higher probability around 0; add up four three-bit-wide randoms [0 .. 28], divide and subtract to get range
|
// Random offset [-8 .. 8], with higher probability around 0; add up four three-bit-wide randoms [0 .. 28], divide and subtract to get range
|
||||||
int OffsetZ = 4 * ((Rnd & 0x07) + ((Rnd & 0x38) >> 3) + ((Rnd & 0x1c0) >> 6) + ((Rnd & 0xe00) >> 9)) / 7 - 8;
|
int OffsetZ = 4 * ((Rnd & 0x07) + ((Rnd & 0x38) >> 3) + ((Rnd & 0x1c0) >> 6) + ((Rnd & 0xe00) >> 9)) / 7 - 8;
|
||||||
Rnd = m_Noise.IntNoise3DInt(a_ChunkX, 512, a_ChunkZ) / 13;
|
Rnd = m_Noise.IntNoise3DInt(a_ChunkX, 512, a_ChunkZ) / 13;
|
||||||
// Random height [0 .. MaxHeight] with preference to center heights
|
// Random height [1 .. MinHeight] with preference to center heights
|
||||||
int HeightY = (((Rnd & 0x1ff) % (MaxHeight + 1)) + (((Rnd >> 9) & 0x1ff) % (MaxHeight + 1))) / 2;
|
int HeightY = 1 + (((Rnd & 0x1ff) % MinHeight) + (((Rnd >> 9) & 0x1ff) % MinHeight)) / 2;
|
||||||
|
|
||||||
a_Lake.SetOrigin(OffsetX, HeightY, OffsetZ);
|
a_Lake.SetOrigin(OffsetX, HeightY, OffsetZ);
|
||||||
|
|
||||||
// Hollow out a few bubbles inside the blockarea:
|
// Hollow out a few bubbles inside the blockarea:
|
||||||
|
@ -96,11 +96,12 @@ class cStructGenLakes :
|
|||||||
public cStructureGen
|
public cStructureGen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cStructGenLakes(int a_Seed, BLOCKTYPE a_Fluid, cTerrainHeightGen & a_HeiGen) :
|
cStructGenLakes(int a_Seed, BLOCKTYPE a_Fluid, cTerrainHeightGen & a_HeiGen, int a_Probability) :
|
||||||
m_Noise(a_Seed),
|
m_Noise(a_Seed),
|
||||||
m_Seed(a_Seed),
|
m_Seed(a_Seed),
|
||||||
m_Fluid(a_Fluid),
|
m_Fluid(a_Fluid),
|
||||||
m_HeiGen(a_HeiGen)
|
m_HeiGen(a_HeiGen),
|
||||||
|
m_Probability(a_Probability)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +110,7 @@ protected:
|
|||||||
int m_Seed;
|
int m_Seed;
|
||||||
BLOCKTYPE m_Fluid;
|
BLOCKTYPE m_Fluid;
|
||||||
cTerrainHeightGen & m_HeiGen;
|
cTerrainHeightGen & m_HeiGen;
|
||||||
|
int m_Probability; ///< Chance, 0 .. 100, of a chunk having the lake
|
||||||
|
|
||||||
// cStructureGen override:
|
// cStructureGen override:
|
||||||
virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
|
virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user