X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgenerator.cpp;h=43d932cceae421473bc391820370c36dccc1fac7;hb=e52e3c500b679ab7bae9cfdda3fb0d630a2584ad;hp=15a15e02fc6f381596bb1dbeb822204012406b1f;hpb=2d5671c2ef977defae9ce0ce7248582ab3e8f011;p=blank.git diff --git a/src/generator.cpp b/src/generator.cpp index 15a15e0..43d932c 100644 --- a/src/generator.cpp +++ b/src/generator.cpp @@ -5,12 +5,13 @@ 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(config.stretch) +, solid_threshold(config.solid_threshold) , space(0) +, light(0) , solids() { } @@ -28,13 +29,22 @@ void Generator::operator ()(Chunk &chunk) const { float val = solidNoise(gen_pos); if (val > solid_threshold) { int type_val = int((typeNoise(gen_pos) + 1.0f) * solids.size()) % solids.size(); - chunk.BlockAt(block_pos) = Block(solids[type_val]); + chunk.SetBlock(block_pos, Block(solids[type_val])); } else { - chunk.BlockAt(block_pos) = Block(space); + chunk.SetBlock(block_pos, Block(space)); } } } } + unsigned int random = 263167 * pos.x + 2097593 * pos.y + 426389 * pos.z; + for (int index = 0; index < Chunk::Size(); ++index) { + if (chunk.IsSurface(index)) { + random = random * 666649 + 7778777; + if ((random % 32) == 0) { + chunk.SetBlock(index, Block(light)); + } + } + } chunk.Invalidate(); chunk.CheckUpdate(); }