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