Added padder feature in Biome and added Sandstone

This commit is contained in:
Namonay
2025-06-01 23:11:39 +02:00
parent 3c90190a90
commit ce9335ba6a
6 changed files with 23 additions and 10 deletions

View File

@@ -5,7 +5,7 @@
#include "NoiseCollection.h"
#include <utility>
Biome::Biome(std::uint32_t filler, std::uint32_t water_level, std::uint32_t water_content, std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>> blocks): filler(filler), water_level(water_level), water_content(water_content), c_blockmap(blocks)
Biome::Biome(std::uint32_t filler, std::uint32_t water_level, std::uint32_t water_content, std::uint32_t padder_block, std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>> blocks): filler(filler), water_level(water_level), water_content(water_content), padder_block(padder_block), c_blockmap(blocks)
{
for (const auto& [height, BlockPlacement] : blocks)
{
@@ -28,7 +28,12 @@ const std::array<std::uint32_t, CHUNK_SIZE.y> Biome::GetBiomeBlocks(const std::u
Scop::FatalError("Biome declaration does not have a value for a certain generated height");
for(std::uint32_t y = ARTIFICIAL_ELEVATION; y < std::min(height, CHUNK_SIZE.y); y++)
{
if(y > std::min(height, CHUNK_SIZE.y) - 2)
if(y > std::min(height, CHUNK_SIZE.y) - 5 && y <= std::min(height, CHUNK_SIZE.y) - 2)
{
data[y] = padder_block;
continue;
}
else if(y > std::min(height, CHUNK_SIZE.y) - 2)
{
const auto& [placementType, blockTypes] = it->second;
switch (static_cast<std::uint8_t>(placementType))

View File

@@ -18,13 +18,14 @@ class Biome
{
public:
Biome(std::uint32_t filler, std::uint32_t water_level, std::uint32_t water_content, std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>> blocks);
Biome(std::uint32_t filler, std::uint32_t water_level, std::uint32_t water_content, std::uint32_t padder_block, std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>> blocks);
~Biome() = default;
const std::array<std::uint32_t, CHUNK_SIZE.y> GetBiomeBlocks(const std::uint32_t height, Scop::Vec2i pos);
private:
const std::uint32_t filler;
const std::uint32_t water_level;
const std::uint32_t water_content;
const std::uint32_t padder_block;
const std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>> c_blockmap;
};

View File

@@ -16,22 +16,24 @@ class BiomeCollection
inline BiomeCollection()
{
m_collection.emplace("grassland", std::make_unique<Biome>(
static_cast<std::uint32_t>(BlockType::Stone),
20,
static_cast<std::uint32_t>(BlockType::Water),
static_cast<std::uint32_t>(BlockType::Stone), // underground block
20, // water level
static_cast<std::uint32_t>(BlockType::Water), // Block to place at water level
static_cast<std::uint32_t>(BlockType::Dirt), // intermediary block
std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>>{
{17, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Dirt}}},
{23, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Sand}}},
{17, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Dirt}}}, // place a dirt block at surface is height <= 17
{23, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Sand}}}, // place a sand block at surface if height > 17 && <= 23
{125, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Grass}}},
{132, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::PseudoRandom, std::vector<BlockType>{BlockType::SnowyGrass, BlockType::Grass}}},
{132, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::PseudoRandom, std::vector<BlockType>{BlockType::SnowyGrass, BlockType::Grass}}}, // Place randomly one of the two blocks at the surface
{140, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::PseudoRandom, std::vector<BlockType>{BlockType::Snow, BlockType::SnowyGrass}}},
{255, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Snow}}}
{255, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Snow}}} // ALWAYS put a block to 255
}
));
m_collection.emplace("tundra", std::make_unique<Biome>(
static_cast<std::uint32_t>(BlockType::Stone),
20,
static_cast<std::uint32_t>(BlockType::Water),
static_cast<std::uint32_t>(BlockType::Stone),
std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>>{
{17, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Dirt}}},
{20, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Ice}}},
@@ -45,7 +47,10 @@ class BiomeCollection
static_cast<std::uint32_t>(BlockType::Stone),
20,
static_cast<std::uint32_t>(BlockType::Water),
static_cast<std::uint32_t>(BlockType::SandStone),
std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>>{
{120, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Sand}}},
{140, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::PseudoRandom, std::vector<BlockType>{BlockType::Sand, BlockType::SandStone}}},
{255, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Sand}}}
}
));

View File

@@ -17,6 +17,7 @@ enum class BlockType : std::uint32_t
SnowyGrass,
Cactus,
Ice,
SandStone,
EndEnum
};

View File

@@ -19,6 +19,7 @@ constexpr std::array<std::array<Scop::Vec2ui, 3>, BlocksCount> BLOCKS_TO_ATLAS =
std::array<Scop::Vec2ui, 3>{ Scop::Vec2ui{ 2, 1 }, Scop::Vec2ui{ 0, 0 }, Scop::Vec2ui{ 3, 1 } }, // SnowyGrass
std::array<Scop::Vec2ui, 3>{ Scop::Vec2ui{ 0, 2 }, Scop::Vec2ui{ 0, 2 }, Scop::Vec2ui{ 0, 2 } }, // Cactus
std::array<Scop::Vec2ui, 3>{ Scop::Vec2ui{ 1, 2 }, Scop::Vec2ui{ 1, 2 }, Scop::Vec2ui{ 1, 2 } }, // Ice
std::array<Scop::Vec2ui, 3>{ Scop::Vec2ui{ 2, 2 }, Scop::Vec2ui{ 2, 2 }, Scop::Vec2ui{ 3, 2 } }, // SandStone
};
enum class Side : std::uint8_t

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB