]> git.localhorst.tv Git - blank.git/blobdiff - src/chunk.cpp
use same load distance for initial and movement
[blank.git] / src / chunk.cpp
index 81c8698db803dbcc3a1e99a4ebe1a9226bf15976..66b049f00366e1ea4a91cb2f0f69d7b200c3d48b 100644 (file)
@@ -263,6 +263,21 @@ int Chunk::GetLight(int index) const {
 }
 
 
+bool Chunk::IsSurface(const Pos &pos) const {
+       const Block &block = BlockAt(pos);
+       if (!Type(block).visible) {
+               return false;
+       }
+       for (int face = 0; face < Block::FACE_COUNT; ++face) {
+               const Block *next = FindNext(pos, Block::Face(face));
+               if (!next || !Type(*next).visible) {
+                       return true;
+               }
+       }
+       return false;
+}
+
+
 void Chunk::Allocate() {
        blocks.resize(Size(), Block(0));
        light.resize(Size(), 0);
@@ -603,8 +618,12 @@ void ChunkLoader::Rebase(const Chunk::Pos &new_base) {
                }
        }
        // add missing new chunks
+       GenerateSurrounding(base);
+}
+
+void ChunkLoader::GenerateSurrounding(const Chunk::Pos &pos) {
        const Chunk::Pos offset(load_dist, load_dist, load_dist);
-       Generate(base - offset, base + offset);
+       Generate(pos - offset, pos + offset);
 }
 
 void ChunkLoader::Update() {