mirror of
https://github.com/Kbz-8/42_vox.git
synced 2026-01-11 14:43:34 +00:00
Added ice & better biome modification
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
#include "NoiseCollection.h"
|
#include "NoiseCollection.h"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
Biome::Biome(std::uint32_t filler, std::uint32_t water_level, std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>> blocks): filler(filler), water_level(water_level), c_blockmap(blocks)
|
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)
|
||||||
{
|
{
|
||||||
for (const auto& [height, BlockPlacement] : blocks)
|
for (const auto& [height, BlockPlacement] : blocks)
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,7 @@ const std::array<std::uint32_t, CHUNK_SIZE.y> Biome::GetBiomeBlocks(const std::u
|
|||||||
|
|
||||||
std::memset(data.data(), static_cast<std::uint32_t>(BlockType::Air), data.size() * sizeof(std::uint32_t));
|
std::memset(data.data(), static_cast<std::uint32_t>(BlockType::Air), data.size() * sizeof(std::uint32_t));
|
||||||
std::fill(data.begin(), data.begin() + ARTIFICIAL_ELEVATION, filler);
|
std::fill(data.begin(), data.begin() + ARTIFICIAL_ELEVATION, filler);
|
||||||
std::fill(data.begin() + ARTIFICIAL_ELEVATION, data.begin() + ARTIFICIAL_ELEVATION + water_level, static_cast<std::uint32_t>(BlockType::Water));
|
std::fill(data.begin() + ARTIFICIAL_ELEVATION, data.begin() + ARTIFICIAL_ELEVATION + water_level, water_content);
|
||||||
auto it = c_blockmap.lower_bound(height - ARTIFICIAL_ELEVATION);
|
auto it = c_blockmap.lower_bound(height - ARTIFICIAL_ELEVATION);
|
||||||
|
|
||||||
if (it == c_blockmap.end())
|
if (it == c_blockmap.end())
|
||||||
|
|||||||
@@ -18,12 +18,13 @@ class Biome
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Biome(std::uint32_t filler, std::uint32_t water_level, 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::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>> blocks);
|
||||||
~Biome() = default;
|
~Biome() = default;
|
||||||
const std::array<std::uint32_t, CHUNK_SIZE.y> GetBiomeBlocks(const std::uint32_t height, Scop::Vec2i pos);
|
const std::array<std::uint32_t, CHUNK_SIZE.y> GetBiomeBlocks(const std::uint32_t height, Scop::Vec2i pos);
|
||||||
private:
|
private:
|
||||||
const std::uint32_t filler;
|
const std::uint32_t filler;
|
||||||
const std::uint32_t water_level;
|
const std::uint32_t water_level;
|
||||||
|
const std::uint32_t water_content;
|
||||||
const std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>> c_blockmap;
|
const std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>> c_blockmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ class BiomeCollection
|
|||||||
m_collection.emplace("grassland", std::make_unique<Biome>(
|
m_collection.emplace("grassland", std::make_unique<Biome>(
|
||||||
static_cast<std::uint32_t>(BlockType::Stone),
|
static_cast<std::uint32_t>(BlockType::Stone),
|
||||||
20,
|
20,
|
||||||
|
static_cast<std::uint32_t>(BlockType::Water),
|
||||||
std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>>{
|
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}}},
|
{23, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Sand}}},
|
||||||
{125, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Grass}}},
|
{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}}},
|
||||||
@@ -29,7 +31,10 @@ class BiomeCollection
|
|||||||
m_collection.emplace("tundra", std::make_unique<Biome>(
|
m_collection.emplace("tundra", std::make_unique<Biome>(
|
||||||
static_cast<std::uint32_t>(BlockType::Stone),
|
static_cast<std::uint32_t>(BlockType::Stone),
|
||||||
20,
|
20,
|
||||||
|
static_cast<std::uint32_t>(BlockType::Water),
|
||||||
std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>>{
|
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}}},
|
||||||
{23, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Snow}}},
|
{23, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Snow}}},
|
||||||
{120, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::SnowyGrass}}},
|
{120, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::SnowyGrass}}},
|
||||||
{140, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::PseudoRandom, std::vector<BlockType>{BlockType::Snow, BlockType::SnowyGrass}}},
|
{140, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::PseudoRandom, std::vector<BlockType>{BlockType::Snow, BlockType::SnowyGrass}}},
|
||||||
@@ -39,6 +44,7 @@ class BiomeCollection
|
|||||||
m_collection.emplace("desert", std::make_unique<Biome>(
|
m_collection.emplace("desert", std::make_unique<Biome>(
|
||||||
static_cast<std::uint32_t>(BlockType::Stone),
|
static_cast<std::uint32_t>(BlockType::Stone),
|
||||||
20,
|
20,
|
||||||
|
static_cast<std::uint32_t>(BlockType::Water),
|
||||||
std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>>{
|
std::map<std::uint32_t, std::pair<BlockPlacementType, std::vector<BlockType>>>{
|
||||||
{255, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Sand}}}
|
{255, std::pair<BlockPlacementType, std::vector<BlockType>>{BlockPlacementType::Simple, std::vector<BlockType>{BlockType::Sand}}}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ enum class BlockType : std::uint32_t
|
|||||||
Snow,
|
Snow,
|
||||||
SnowyGrass,
|
SnowyGrass,
|
||||||
Cactus,
|
Cactus,
|
||||||
|
Ice,
|
||||||
|
|
||||||
EndEnum
|
EndEnum
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ constexpr std::array<std::array<Scop::Vec2ui, 3>, BlocksCount> BLOCKS_TO_ATLAS =
|
|||||||
std::array<Scop::Vec2ui, 3>{ Scop::Vec2ui{ 2, 1 }, Scop::Vec2ui{ 2, 1 }, Scop::Vec2ui{ 2, 1 } }, // Snow
|
std::array<Scop::Vec2ui, 3>{ Scop::Vec2ui{ 2, 1 }, Scop::Vec2ui{ 2, 1 }, Scop::Vec2ui{ 2, 1 } }, // Snow
|
||||||
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{ 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{ 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 } }, // Cactus
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class Side : std::uint8_t
|
enum class Side : std::uint8_t
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Reference in New Issue
Block a user