X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fchunk.cpp;fp=src%2Fchunk.cpp;h=23d5a13c260e8dfdefab8e5ec3f444a8a537967f;hb=35c09fc00094a3d390732fd533b2bd03413d90c7;hp=74ca1bcf96933274f9560cbb151e8629177eeb0c;hpb=4ef32c5a4a5bdb6da8383f66d8265715eb2ed4f9;p=blank.git diff --git a/src/chunk.cpp b/src/chunk.cpp index 74ca1bc..23d5a13 100644 --- a/src/chunk.cpp +++ b/src/chunk.cpp @@ -445,7 +445,7 @@ void Chunk::Update() { for (size_t i = 0; i < Size(); ++i) { const BlockType &type = Type(blocks[i]); - if (!type.visible || Obstructed(i)) continue; + if (!type.visible || Obstructed(i).All()) continue; type.FillBlockModel(buf, ToTransform(i), vtx_counter); size_t vtx_begin = vtx_counter; @@ -464,18 +464,19 @@ void Chunk::Update() { dirty = false; } -bool Chunk::Obstructed(int idx) const { +Block::FaceSet Chunk::Obstructed(int idx) const { Chunk::Pos pos(ToPos(idx)); + Block::FaceSet result; for (int f = 0; f < Block::FACE_COUNT; ++f) { Block::Face face = Block::Face(f); BlockLookup next(const_cast(this), pos, face); - if (!next || !next.GetType().FaceFilled(next.GetBlock(), Block::Opposite(face))) { - return false; + if (next && next.GetType().FaceFilled(next.GetBlock(), Block::Opposite(face))) { + result.Set(face); } } - return true; + return result; } glm::mat4 Chunk::ToTransform(int idx) const {