1
0

Changed CubicNoiseXX to IntNoiseXX

Added some comments
This commit is contained in:
STRWarrior 2014-07-20 22:43:31 +02:00
parent 76b79b51ad
commit a4470da876
2 changed files with 49 additions and 40 deletions

View File

@ -166,34 +166,45 @@ 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)
{ {
continue;
}
for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--) for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--)
{ {
// Check if long grass can be placed.
if ( if (
(a_ChunkDesc.GetBlockType(x, y, z) == E_BLOCK_AIR) && (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)) ((a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_GRASS) && (a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_DIRT))
) )
{ {
float GrassType = m_Noise.CubicNoise2D(xx * 50, zz * 50); continue;
if (GrassType < 0.2f) }
// 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); a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1);
} }
else if (GrassType < 0.8f) else if (GrassType < 90)
{ {
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2); a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2);
} }
else 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) if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR)
{ {
NIBBLETYPE Meta = m_Noise.CubicNoise2D(xx * 100, zz * 100) > -0.5f ? 2 : 3; NIBBLETYPE Meta = (m_Noise.IntNoise2DInt(xx * 100, zz * 100) / 7 % 100) > 25 ? 2 : 3;
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta); 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 + 1, z, E_BLOCK_BIG_FLOWER, 8);
} }
@ -201,8 +212,6 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc)
} }
} }
} }
}
}
} }

View File

@ -82,7 +82,7 @@ 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)
{ {
@ -92,11 +92,11 @@ protected:
case biSavannaPlateauM: case biSavannaPlateauM:
case biPlains: case biPlains:
{ {
return 0.4f; return 70;
} }
default: default:
{ {
return -0.6f; return 20;
} }
} }
} }