diff --git a/Application/Biome.cpp b/Application/Biome.cpp index 8934e28..bf4b613 100644 --- a/Application/Biome.cpp +++ b/Application/Biome.cpp @@ -1,8 +1,7 @@ -#include +#include "Biome.h" #include "Block.h" #include "Chunk.h" -#include "Maths/Vec3.h" #include Biome::Biome(std::uint32_t filler, std::uint32_t water_level, std::map>> blocks): filler(filler), water_level(water_level), c_blockmap(blocks) @@ -27,8 +26,6 @@ const std::array Biome::GetBiomeBlocks(const std::u { if(y > std::min(height, CHUNK_SIZE.y) - 2) { - data[y] = static_cast(BlockType::Dirt); - continue; const auto& [placementType, blockTypes] = it->second; switch (static_cast(placementType)) { diff --git a/Application/Biome.h b/Application/Biome.h index 95dcf3c..1c5b347 100644 --- a/Application/Biome.h +++ b/Application/Biome.h @@ -1,7 +1,7 @@ #ifndef BIOME_H #define BIOME_H -#include +#include "Block.h" #include "Chunk.h" #include "Maths/Vec2.h" #include diff --git a/Application/BiomeCollection.h b/Application/BiomeCollection.h index a5e4b3f..85960d0 100644 --- a/Application/BiomeCollection.h +++ b/Application/BiomeCollection.h @@ -14,13 +14,13 @@ class BiomeCollection public: inline BiomeCollection() { - m_collection.emplace("grassland", std::make_unique(Biome( + m_collection.emplace("grassland", std::make_unique( static_cast(BlockType::Stone), 0, { {20, {BlockPlacementType::Simple, {BlockType::Sand}}}, {255, {BlockPlacementType::Simple, {BlockType::Snow}}} - }) + } )); }; const std::array GetBiomeBlocks(std::string biome, std::uint32_t height, Scop::Vec2i pos) const; diff --git a/Application/NoiseCollection.cpp b/Application/NoiseCollection.cpp index 53c6768..1033a73 100644 --- a/Application/NoiseCollection.cpp +++ b/Application/NoiseCollection.cpp @@ -23,6 +23,8 @@ const std::array NoiseCollection::GetBlocks(Scop::V std::memset(data.data(), static_cast(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); @@ -59,5 +61,9 @@ const std::array NoiseCollection::GetBlocks(Scop::V if(data[y] == static_cast(BlockType::Air)) data[y] = static_cast(BlockType::Water); } + const std::uint32_t biome_value = m_collection["biomes"]->Perlin2D(pos.x, pos.y); + + if (biome_value > 20) + data[240] = static_cast(BlockType::Stone); return data; } diff --git a/Application/NoiseCollection.h b/Application/NoiseCollection.h index 0b94b71..7bcdef6 100644 --- a/Application/NoiseCollection.h +++ b/Application/NoiseCollection.h @@ -1,6 +1,7 @@ #ifndef NOISECOLLECTION_H -# define NOISECOLLECTION_H +# define NOISECOLLECTION_H +#include #include #include #include @@ -13,7 +14,7 @@ constexpr std::uint32_t WATER_LEVEL = 20; class NoiseCollection { public: - inline NoiseCollection(const std::uint32_t seed) + inline NoiseCollection(const std::uint32_t seed): c_biomecollection() { m_collection.emplace("terrain", std::make_unique(seed, // seed 0.045f, @@ -33,6 +34,15 @@ class NoiseCollection 3, 1.0f )); // TODO !!!!!! + m_collection.emplace("biomes", std::make_unique(seed, + 0.05f, + 1.0f, + 1, + 2.0f, + 0.5f, + 1, + 1.0f + )); } Noise* GetNoise(const std::string& key) const; @@ -43,6 +53,7 @@ class NoiseCollection private: std::unordered_map> m_collection; + const BiomeCollection c_biomecollection; }; #endif