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
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);
// 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))