X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgenerator.cpp;h=3714065c6dc54ef6cae1d2bd00fc97c19af397c4;hb=76b3ec0f6aa0dacf6d4944a2787991f3585299e8;hp=43d932cceae421473bc391820370c36dccc1fac7;hpb=f90ec88e6728ce865bcf892c810a36abd90d9001;p=blank.git diff --git a/src/generator.cpp b/src/generator.cpp index 43d932c..3714065 100644 --- a/src/generator.cpp +++ b/src/generator.cpp @@ -5,10 +5,10 @@ namespace blank { -Generator::Generator(const Config &config) +Generator::Generator(const Config &config) noexcept : solidNoise(config.solid_seed) , typeNoise(config.type_seed) -, stretch(config.stretch) +, stretch(1.0f/config.stretch) , solid_threshold(config.solid_threshold) , space(0) , light(0) @@ -17,16 +17,15 @@ Generator::Generator(const Config &config) } -void Generator::operator ()(Chunk &chunk) const { - chunk.Allocate(); +void Generator::operator ()(Chunk &chunk) const noexcept { Chunk::Pos pos(chunk.Position()); glm::vec3 coords(pos * Chunk::Extent()); for (int z = 0; z < Chunk::Depth(); ++z) { for (int y = 0; y < Chunk::Height(); ++y) { for (int x = 0; x < Chunk::Width(); ++x) { Block::Pos block_pos(x, y, z); - glm::vec3 gen_pos = (coords + block_pos) / stretch; - float val = solidNoise(gen_pos); + glm::vec3 gen_pos = (coords + block_pos) * stretch; + float val = OctaveNoise(solidNoise, coords + block_pos, 3, 0.5f, stretch, 2.0f); if (val > solid_threshold) { int type_val = int((typeNoise(gen_pos) + 1.0f) * solids.size()) % solids.size(); chunk.SetBlock(block_pos, Block(solids[type_val]));