From 23d88e5f1c8f0c8652a07050fcfa8ff126e85d4a Mon Sep 17 00:00:00 2001 From: Mel Date: Fri, 21 Jul 2023 02:17:03 +0200 Subject: Extremely simple chunk-limited lighting --- src/World/Generation/Decoration.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/World/Generation/Decoration.cpp') diff --git a/src/World/Generation/Decoration.cpp b/src/World/Generation/Decoration.cpp index f3f7c46..bcabffa 100644 --- a/src/World/Generation/Decoration.cpp +++ b/src/World/Generation/Decoration.cpp @@ -7,8 +7,10 @@ void Decorator::put_block(Chunk& chunk, Pos pos, BlockType block) { if (!Chunk::is_valid_position(pos.x(), pos.y(), pos.z())) { return; } - if (chunk.is_empty(pos.x(), pos.y(), pos.z())) { - chunk.set(pos.x(), pos.y(), pos.z(), {block}); + + auto& place = chunk.at(pos.x(), pos.y(), pos.z()); + if (place.empty()) { + place = {block}; } } @@ -48,7 +50,7 @@ void TreeDecorator::decorate_chunk(Chunk& chunk) { if (!is_valid_position(pos)) continue; - auto block_below = chunk.get(x, y-1, z); + auto& block_below = chunk.at(x, y-1, z); if (block_below.empty()) continue; @@ -64,7 +66,7 @@ void TreeDecorator::decorate_chunk(Chunk& chunk) { continue; draw_tree(chunk, pos); - chunk.set(x, y-1, z, {BlockType::Dirt}); + block_below = {BlockType::Dirt}; last_tree = pos; break; } -- cgit 1.4.1