X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fchunk.cpp;h=77899e79d5da360506502ae8954e54bf56648a3c;hb=7bb75960dbf9bfdee9ac865384aca81791b3da5c;hp=190fe3d7b9e4c4aa25d4fbaf6745845c97b0565b;hpb=5998b18978bd8e7a0c9deb516474634e1d3521c9;p=blank.git diff --git a/src/world/chunk.cpp b/src/world/chunk.cpp index 190fe3d..77899e7 100644 --- a/src/world/chunk.cpp +++ b/src/world/chunk.cpp @@ -842,9 +842,20 @@ void ChunkLoader::Update(int dt) { // check if a chunk generation is scheduled for this frame // and if there's a chunk waiting to be generated gen_timer.Update(dt); - if (!gen_timer.Hit() || to_generate.empty()) { - return; + if (gen_timer.Hit()) { + LoadOne(); + } +} + +void ChunkLoader::LoadN(std::size_t n) { + std::size_t end = std::min(n, ToLoad()); + for (std::size_t i = 0; i < end; ++i) { + LoadOne(); } +} + +void ChunkLoader::LoadOne() { + if (to_generate.empty()) return; // take position of next chunk in queue Chunk::Pos pos(to_generate.front());