]> git.localhorst.tv Git - blank.git/blobdiff - src/generator.cpp
update light levels from border on neighbor change
[blank.git] / src / generator.cpp
index c1a7a0801198de34e3a4b8b3d0bdddd70f334ba4..373374fa45447fa17daaf0f58ac356c4af589795 100644 (file)
@@ -5,11 +5,11 @@
 
 namespace blank {
 
-Generator::Generator(unsigned int seed)
-: solidNoise(seed)
-, typeNoise(seed + 1)
-, stretch(64.0f)
-, solid_threshold(0.8f)
+Generator::Generator(const Config &config)
+: solidNoise(config.solid_seed)
+, typeNoise(config.type_seed)
+, stretch(1.0f/config.stretch)
+, solid_threshold(config.solid_threshold)
 , space(0)
 , light(0)
 , solids() {
@@ -18,15 +18,14 @@ Generator::Generator(unsigned int seed)
 
 
 void Generator::operator ()(Chunk &chunk) const {
-       chunk.Allocate();
        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]));