]> git.localhorst.tv Git - blank.git/commitdiff
propagate light into blocking blocks
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 23 Jul 2015 07:21:00 +0000 (09:21 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 23 Jul 2015 07:24:35 +0000 (09:24 +0200)
this way semi-filled blocks like slabs don't blacken surfaces
behind them, but they will be bright when part of a 1 thick wall

TODO
src/world/chunk.cpp
tst/world/ChunkTest.cpp

diff --git a/TODO b/TODO
index 7e52a23ba4b940e4b9bab1bc13a8474ac3a15f39..5fc2e9e5f32f0398479bb35030c532bf1d1d0794 100644 (file)
--- a/TODO
+++ b/TODO
@@ -54,6 +54,10 @@ entity ai
        I kinda mitigated it a little for direct neighbors during linking, but
        it still can happen in (hopefully) rare corner cases
 
+       propagation through semi-filled blocks is wonky. I worked around it by
+       having the light propagate into solid blocks, but feels like this
+       could cause some weird behaviours
+
 gravity
 
        maybe like light levels? should also store a direction with it in
index ef3c5fc869d80acb94d4ec054462ce2d85c9cc64..c421be9d679fa45e0e715ab2c2feeddf7b3230cf 100644 (file)
@@ -65,9 +65,13 @@ struct SetNode {
        int Get() const noexcept { return chunk->GetLight(pos); }
        void Set(int level) noexcept { chunk->SetLight(pos, level); }
 
+       const BlockType &GetType() const noexcept { return chunk->Type(Chunk::ToIndex(pos)); }
+
        bool HasNext(Block::Face face) noexcept {
+               const BlockType &type = GetType();
+               if (type.block_light && !type.luminosity) return false;
                const BlockLookup next(chunk, pos, face);
-               return next && !next.GetType().block_light;
+               return next;
        }
        SetNode GetNext(Block::Face face) noexcept {
                const BlockLookup next(chunk, pos, face);
index 6db245a2d7d5cd58182c0cef956abaa3c85745fa..c8dac8319f30835cbacf20a6b9c3d4391db1531a 100644 (file)
@@ -450,10 +450,6 @@ void ChunkTest::testLightPropagation() {
 
        // now block the light to the left
        chunk->SetBlock(Chunk::Pos(6, 7, 7), Block(1));
-       CPPUNIT_ASSERT_EQUAL_MESSAGE(
-               "non-zero light level in solid block",
-               0, chunk->GetLight(Chunk::Pos(6, 7, 7))
-       );
        CPPUNIT_ASSERT_EQUAL_MESSAGE(
                "adding obstacle affected unrelated index",
                5, chunk->GetLight(Chunk::Pos(7, 7, 7))