feat: improve mountain realism

This commit is contained in:
2026-05-22 20:33:38 +08:00
parent 17c7ad989d
commit ca4d767a52
6 changed files with 85 additions and 39 deletions

View File

@@ -7,8 +7,15 @@ namespace Cubed {
constexpr float BIOME_NOISE_FREQUENCY = 0.03f;
constexpr float HEIGHTMAP_NOISE_FREQUENCY = 0.001f;
constexpr float MOUNTAINOUS_NOISE_FREQUENCY = 0.003f;
enum class BiomeType { PLAIN = 0, FOREST, DESERT, MOUNTAIN, RIVER, NONE };
struct BiomeConditions {
float temp = 0.0f;
float humid = 0.0f;
float mountainous = 0.0f;
};
struct BiomeHeightRange {
int base_y;
int amplitude;
@@ -47,13 +54,14 @@ struct MountainParams : public BaseBiomeParams {};
struct RiverParams : public BaseBiomeParams {};
std::string get_biome_str(BiomeType biome);
BiomeType get_biome_from_noise(float temp, float humid);
std::array<float, 3> get_noise_frequencies_for_biome(BiomeType biome);
BiomeHeightRange get_biome_height_range(BiomeType biome);
BiomeType safe_int_to_biome(int x);
int get_interpolated_height(float world_x, float world_z, float temp,
float humid);
BiomeType determine_biome(const BiomeConditions& conditions);
PlainParams& plain_params();
ForestParams& forest_params();
DesertParams& desert_params();

View File

@@ -38,6 +38,9 @@ private:
float frequency = 0.01f;
float height = 80;
unsigned m_seed = 0;
BiomeConditions m_conditions;
void clear_dirty();
public:
@@ -108,6 +111,7 @@ public:
std::vector<BlockType>& blocks();
World& world();
unsigned seed() const;
BiomeConditions& conditions();
};
} // namespace Cubed