diff options
| author | Mel <einebeere@gmail.com> | 2023-07-21 02:17:03 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2023-07-21 02:17:03 +0200 |
| commit | 23d88e5f1c8f0c8652a07050fcfa8ff126e85d4a (patch) | |
| tree | d2979c12a9675885b7ed969d5f51dbd69d969286 /src/World/Generation/Decoration.cpp | |
| parent | c0556f76fc5c8271c2eaa7ca91ad1c92c691d8bc (diff) | |
| download | meowcraft-23d88e5f1c8f0c8652a07050fcfa8ff126e85d4a.tar.zst meowcraft-23d88e5f1c8f0c8652a07050fcfa8ff126e85d4a.zip | |
Extremely simple chunk-limited lighting
Diffstat (limited to 'src/World/Generation/Decoration.cpp')
| -rw-r--r-- | src/World/Generation/Decoration.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
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; } |
