Changed CubicNoiseXX to IntNoiseXX
Added some comments
This commit is contained in:
parent
76b79b51ad
commit
a4470da876
@ -166,38 +166,47 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc)
|
|||||||
{
|
{
|
||||||
for (int x = 0; x < cChunkDef::Width; x++)
|
for (int x = 0; x < cChunkDef::Width; x++)
|
||||||
{
|
{
|
||||||
float xx = (float) x + a_ChunkDesc.GetChunkX();
|
int xx = x + a_ChunkDesc.GetChunkX() * cChunkDef::Width;
|
||||||
for (int z = 0; z < cChunkDef::Width; z++)
|
for (int z = 0; z < cChunkDef::Width; z++)
|
||||||
{
|
{
|
||||||
float zz = (float) z + a_ChunkDesc.GetChunkZ();
|
int zz = z + a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
|
||||||
float BiomeDensity = GetBiomeDensity(a_ChunkDesc.GetBiome(x, z));
|
int BiomeDensity = GetBiomeDensity(a_ChunkDesc.GetBiome(x, z));
|
||||||
if (m_Noise.CubicNoise2D(xx + m_Noise.CubicNoise1D(xx), zz + m_Noise.CubicNoise1D(zz)) < BiomeDensity)
|
|
||||||
|
// Choose if we want to place long grass here. If not then bail out.
|
||||||
|
if ((m_Noise.IntNoise2DInt(xx + m_Noise.IntNoise1DInt(xx), zz + m_Noise.IntNoise1DInt(zz)) / 7 % 100) > BiomeDensity)
|
||||||
{
|
{
|
||||||
for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--)
|
continue;
|
||||||
{
|
}
|
||||||
if (
|
|
||||||
(a_ChunkDesc.GetBlockType(x, y, z) == E_BLOCK_AIR) &&
|
for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--)
|
||||||
((a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_GRASS) || (a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_DIRT))
|
{
|
||||||
|
// Check if long grass can be placed.
|
||||||
|
if (
|
||||||
|
(a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) ||
|
||||||
|
((a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_GRASS) && (a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_DIRT))
|
||||||
)
|
)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Choose what long grass meta we should use.
|
||||||
|
int GrassType = m_Noise.IntNoise2DInt(xx * 50, zz * 50) / 7 % 100;
|
||||||
|
if (GrassType < 60)
|
||||||
|
{
|
||||||
|
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1);
|
||||||
|
}
|
||||||
|
else if (GrassType < 90)
|
||||||
|
{
|
||||||
|
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If double long grass we have to choose what type we should use.
|
||||||
|
if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR)
|
||||||
{
|
{
|
||||||
float GrassType = m_Noise.CubicNoise2D(xx * 50, zz * 50);
|
NIBBLETYPE Meta = (m_Noise.IntNoise2DInt(xx * 100, zz * 100) / 7 % 100) > 25 ? 2 : 3;
|
||||||
if (GrassType < 0.2f)
|
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta);
|
||||||
{
|
a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8);
|
||||||
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1);
|
|
||||||
}
|
|
||||||
else if (GrassType < 0.8f)
|
|
||||||
{
|
|
||||||
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR)
|
|
||||||
{
|
|
||||||
NIBBLETYPE Meta = m_Noise.CubicNoise2D(xx * 100, zz * 100) > -0.5f ? 2 : 3;
|
|
||||||
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta);
|
|
||||||
a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,22 +82,22 @@ protected:
|
|||||||
// cFinishGen override:
|
// cFinishGen override:
|
||||||
virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
|
virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
|
||||||
|
|
||||||
float GetBiomeDensity(EMCSBiome a_Biome)
|
int GetBiomeDensity(EMCSBiome a_Biome)
|
||||||
{
|
{
|
||||||
switch (a_Biome)
|
switch (a_Biome)
|
||||||
{
|
{
|
||||||
case biSavanna:
|
case biSavanna:
|
||||||
case biSavannaM:
|
case biSavannaM:
|
||||||
case biSavannaPlateau:
|
case biSavannaPlateau:
|
||||||
case biSavannaPlateauM:
|
case biSavannaPlateauM:
|
||||||
case biPlains:
|
case biPlains:
|
||||||
{
|
{
|
||||||
return 0.4f;
|
return 70;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
return -0.6f;
|
return 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user