mirror of
https://github.com/Kbz-8/42_vox.git
synced 2026-03-04 04:56:37 +00:00
Better biome generation w/ temperature & humidity
This commit is contained in:
@@ -20,50 +20,14 @@ const std::array<std::uint32_t, CHUNK_SIZE.y> NoiseCollection::GetBlocks(Scop::V
|
||||
{
|
||||
const std::uint32_t height = m_collection["terrain"]->Perlin2D(pos.x, pos.y) + ARTIFICIAL_ELEVATION;
|
||||
std::array<std::uint32_t, CHUNK_SIZE.y> data;
|
||||
|
||||
std::memset(data.data(), static_cast<std::uint32_t>(BlockType::Air), data.size() * sizeof(std::uint32_t));
|
||||
|
||||
data = c_biomecollection.GetBiomeBlocks("grassland", height, pos);
|
||||
return data;
|
||||
for(std::uint32_t y = 0; y < std::min(height, CHUNK_SIZE.y); y++)
|
||||
{
|
||||
// const std::uint32_t value = Perlin3D(pos.x, y, pos.y);
|
||||
if(y > std::min(height, CHUNK_SIZE.y) - 2)
|
||||
{
|
||||
if(height <= 23 + ARTIFICIAL_ELEVATION)
|
||||
data[y] = static_cast<std::uint32_t>(BlockType::Sand);
|
||||
else if(height < 125 + ARTIFICIAL_ELEVATION)
|
||||
data[y] = static_cast<std::uint32_t>(BlockType::Grass);
|
||||
else if (height < 132 + ARTIFICIAL_ELEVATION)
|
||||
{
|
||||
float weight = sin(2 * (pos.x * pos.y)) + sin(Scop::Pi<float>() * (pos.x * pos.y));
|
||||
if (weight > 0.0f)
|
||||
data[y] = static_cast<std::uint32_t>(BlockType::Grass);
|
||||
else
|
||||
data[y] = static_cast<std::uint32_t>(BlockType::SnowyGrass);
|
||||
}
|
||||
else if (height < 140 + ARTIFICIAL_ELEVATION)
|
||||
{
|
||||
float weight = sin(2 * (pos.x * pos.y)) + sin(Scop::Pi<float>() * (pos.x * pos.y));
|
||||
if (weight > 0.0f)
|
||||
data[y] = static_cast<std::uint32_t>(BlockType::Snow);
|
||||
else
|
||||
data[y] = static_cast<std::uint32_t>(BlockType::SnowyGrass);
|
||||
}
|
||||
else
|
||||
data[y] = static_cast<std::uint32_t>(BlockType::Snow);
|
||||
}
|
||||
else
|
||||
data[y] = static_cast<std::uint32_t>(BlockType::Stone);
|
||||
}
|
||||
for(std::uint32_t y = 0; y < ARTIFICIAL_ELEVATION + WATER_LEVEL; y++)
|
||||
{
|
||||
if(data[y] == static_cast<std::uint32_t>(BlockType::Air))
|
||||
data[y] = static_cast<std::uint32_t>(BlockType::Water);
|
||||
}
|
||||
const std::uint32_t biome_value = m_collection["biomes"]->Perlin2D(pos.x, pos.y);
|
||||
|
||||
if (biome_value > 20)
|
||||
data[240] = static_cast<std::uint32_t>(BlockType::Stone);
|
||||
return data;
|
||||
const std::uint32_t temperature = m_collection["temperature"]->Perlin2D(pos.x, pos.y);
|
||||
const std::uint32_t humidity = m_collection["humidity"]->Perlin2D(pos.x, pos.y);
|
||||
if (temperature < 85 && humidity <= 110)
|
||||
return c_biomecollection.GetBiomeBlocks("tundra", height, pos);
|
||||
if (temperature >= 85 && temperature <= 145 && humidity >= 85)
|
||||
return c_biomecollection.GetBiomeBlocks("grassland", height, pos);
|
||||
if (temperature >= 145)
|
||||
return c_biomecollection.GetBiomeBlocks("desert", height, pos);
|
||||
return c_biomecollection.GetBiomeBlocks("grassland", height, pos);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user