X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FGenerator.hpp;h=e431f7debbd02a588d1d118250795f0e07248a34;hb=dcd54cacda98c2c0f7cf0c7a9131fb858d8ee10a;hp=a2ae18a3e99fa56450f57c88abd8e4deea8d2f33;hpb=b7d09e1e35ef90282c97509e0020b20db3c7ea9f;p=blank.git diff --git a/src/world/Generator.hpp b/src/world/Generator.hpp index a2ae18a..e431f7d 100644 --- a/src/world/Generator.hpp +++ b/src/world/Generator.hpp @@ -1,45 +1,60 @@ #ifndef BLANK_WORLD_GENERATOR_HPP_ #define BLANK_WORLD_GENERATOR_HPP_ -#include "Block.hpp" +#include "../graphics/glm.hpp" #include "../rand/SimplexNoise.hpp" -#include "../rand/WorleyNoise.hpp" +#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; + struct ValueField; + Block Generate(const ValueField &, const glm::ivec3 &position) const 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; };