X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fchunk.cpp;h=66b049f00366e1ea4a91cb2f0f69d7b200c3d48b;hb=32a2a1231de8438f8408007c41247361b1c52417;hp=81c8698db803dbcc3a1e99a4ebe1a9226bf15976;hpb=b368ecb2c0f34e27b1d3b97cceb218b554dee324;p=blank.git diff --git a/src/chunk.cpp b/src/chunk.cpp index 81c8698..66b049f 100644 --- a/src/chunk.cpp +++ b/src/chunk.cpp @@ -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() {