1 #include "generator.hpp"
8 Generator::Generator(unsigned int seed)
12 , solid_threshold(0.8f)
18 void Generator::operator ()(Chunk &chunk) const {
20 Chunk::Pos pos(chunk.Position());
21 glm::vec3 coords(pos * Chunk::Extent());
22 for (int z = 0; z < Chunk::Depth(); ++z) {
23 for (int y = 0; y < Chunk::Height(); ++y) {
24 for (int x = 0; x < Chunk::Width(); ++x) {
25 Block::Pos block_pos(x, y, z);
26 glm::vec3 gen_pos = (coords + block_pos) / stretch;
27 float val = solidNoise(gen_pos);
28 if (val > solid_threshold) {
29 int type_val = int((typeNoise(gen_pos) + 1.0f) * solids.size()) % solids.size();
30 chunk.BlockAt(block_pos) = Block(solids[type_val]);