X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FGenerator.hpp;h=cf94356a482ccfd2a5e028a83975d027f63c11c9;hb=1bc2f230105ad6e1ee8d999ddc079cd85d244bf9;hp=a2ae18a3e99fa56450f57c88abd8e4deea8d2f33;hpb=b7d09e1e35ef90282c97509e0020b20db3c7ea9f;p=blank.git diff --git a/src/world/Generator.hpp b/src/world/Generator.hpp index a2ae18a..cf94356 100644 --- a/src/world/Generator.hpp +++ b/src/world/Generator.hpp @@ -1,45 +1,63 @@ #ifndef BLANK_WORLD_GENERATOR_HPP_ #define BLANK_WORLD_GENERATOR_HPP_ -#include "Block.hpp" #include "../rand/SimplexNoise.hpp" -#include "../rand/WorleyNoise.hpp" +#include #include +#include namespace blank { +class Block; +class BlockType; +class BlockTypeRegistry; class Chunk; class Generator { public: struct Config { - unsigned int solid_seed = 0; - unsigned int type_seed = 0; - float stretch = 64.0f; - float solid_threshold = 0.5f; + std::uint64_t seed = 0; + struct NoiseParam { + std::uint64_t seed_mask; + int octaves; + float persistence; + float frequency; + float amplitude; + float growth; + }; + NoiseParam solidity = { 0xA85033F6BCBDD110, 3, 0.5f, 1.0f/64.0f, 2.0f, 2.0f }; + NoiseParam humidity = { 0x3A463FB24B04A901, 2, 0.5f, 1.0f/512.0f, 2.0f, 2.0f }; + NoiseParam temperature = { 0x2530BA6C6134A9FB, 2, 0.5f, 1.0f/1024.0f, 2.0f, 2.0f }; + NoiseParam richness = { 0x95A179F180103446, 3, 0.5f, 1.0f/128.0f, 2.0f, 2.0f }; + NoiseParam randomness = { 0x074453EEE1496390, 3, 0.5f, 1.0f/16.0f, 2.0f, 2.0f }; }; explicit Generator(const Config &) noexcept; - void operator ()(Chunk &) const noexcept; + void LoadTypes(const BlockTypeRegistry &); - void Space(Block::Type t) noexcept { space = t; } - void Light(Block::Type t) noexcept { light = t; } - void Solids(const std::vector &s) { solids = s; } + void operator ()(Chunk &) const noexcept; private: - SimplexNoise solidNoise; - WorleyNoise typeNoise; + Block Generate(const glm::vec3 &position) const noexcept; + static float GetValue( + const SimplexNoise &, + const glm::vec3 &, + const Config::NoiseParam &) noexcept; - float stretch; - float solid_threshold; - - Block::Type space; - Block::Type light; - std::vector solids; +private: + const Config &config; + std::vector types; + float min_solidity; + + SimplexNoise solidity_noise; + SimplexNoise humidity_noise; + SimplexNoise temperature_noise; + SimplexNoise richness_noise; + SimplexNoise random_noise; };