]> git.localhorst.tv Git - blank.git/blobdiff - src/world/Generator.hpp
some code reorganization
[blank.git] / src / world / Generator.hpp
diff --git a/src/world/Generator.hpp b/src/world/Generator.hpp
new file mode 100644 (file)
index 0000000..a2ae18a
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef BLANK_WORLD_GENERATOR_HPP_
+#define BLANK_WORLD_GENERATOR_HPP_
+
+#include "Block.hpp"
+#include "../rand/SimplexNoise.hpp"
+#include "../rand/WorleyNoise.hpp"
+
+#include <vector>
+
+
+namespace blank {
+
+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;
+       };
+
+       explicit Generator(const Config &) noexcept;
+
+       void operator ()(Chunk &) const noexcept;
+
+       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; }
+
+private:
+       SimplexNoise solidNoise;
+       WorleyNoise typeNoise;
+
+       float stretch;
+       float solid_threshold;
+
+       Block::Type space;
+       Block::Type light;
+       std::vector<Block::Type> solids;
+
+};
+
+}
+
+#endif