]> git.localhorst.tv Git - blank.git/blobdiff - src/world/Generator.hpp
glm backwards compatibility
[blank.git] / src / world / Generator.hpp
index b3cb61f891e5bef8f8535f5a4a52980747f9145f..e431f7debbd02a588d1d118250795f0e07248a34 100644 (file)
@@ -1,44 +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 <cstdint>
 #include <vector>
 
 
 namespace blank {
 
+class Block;
+class BlockType;
+class BlockTypeRegistry;
 class Chunk;
 
 class Generator {
 
 public:
        struct Config {
-               unsigned int 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<Block::Type> &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<Block::Type> solids;
+private:
+       const Config &config;
+       std::vector<const BlockType *> types;
+       float min_solidity;
+
+       SimplexNoise solidity_noise;
+       SimplexNoise humidity_noise;
+       SimplexNoise temperature_noise;
+       SimplexNoise richness_noise;
+       SimplexNoise random_noise;
 
 };