From 33a9e73a4f9ed21c59a321fedeb4277318531abe Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 10 Nov 2015 17:42:48 +0100 Subject: [PATCH] =?utf8?q?maybe=20fixed=20a=20lighting=20bug=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit …that was practically inexistent --- src/world/chunk.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/world/chunk.cpp b/src/world/chunk.cpp index 9e95458..fb43755 100644 --- a/src/world/chunk.cpp +++ b/src/world/chunk.cpp @@ -84,6 +84,9 @@ struct SetNode { const BlockType &GetType() const noexcept { return chunk->Type(Chunk::ToIndex(pos)); } + int EmitLevel() const noexcept { return GetType().luminosity; } + bool EmitsLight() const noexcept { return EmitLevel() > 0; } + bool HasNext(Block::Face face) noexcept { const BlockType &type = GetType(); if (type.block_light && !type.luminosity) return false; @@ -146,9 +149,13 @@ void work_dark() noexcept { for (int face = 0; face < Block::FACE_COUNT; ++face) { if (node.HasNext(Block::Face(face))) { UnsetNode other = node.GetNext(Block::Face(face)); - // TODO: if there a light source here with the same level this will err if (other.Get() != 0 && other.Get() < node.level) { - other.Set(0); + if (other.EmitsLight()) { + other.Set(other.EmitLevel()); + light_queue.emplace(other); + } else { + other.Set(0); + } dark_queue.emplace(other); } else { light_queue.emplace(other); -- 2.39.2