diff options
| author | Mel <einebeere@gmail.com> | 2023-07-29 17:31:10 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2023-07-29 17:31:10 +0200 |
| commit | 15352db7bc03a176ea7a184f40a7f4e72b54b5fe (patch) | |
| tree | e826870299577e2c6b0ecc79171f8a6accaa6a51 /src/World/Generation/Decoration.cpp | |
| parent | 6b69d4b5b648253f894707723af0e2eae9f71445 (diff) | |
| download | meowcraft-15352db7bc03a176ea7a184f40a7f4e72b54b5fe.tar.zst meowcraft-15352db7bc03a176ea7a184f40a7f4e72b54b5fe.zip | |
Add default light to just-generated chunks
Diffstat (limited to 'src/World/Generation/Decoration.cpp')
| -rw-r--r-- | src/World/Generation/Decoration.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/World/Generation/Decoration.cpp b/src/World/Generation/Decoration.cpp index bcabffa..556b5e7 100644 --- a/src/World/Generation/Decoration.cpp +++ b/src/World/Generation/Decoration.cpp @@ -45,7 +45,7 @@ void TreeDecorator::decorate_chunk(Chunk& chunk) { Pos last_tree = Pos::max(); for (UInt x = 0; x < Chunk::Width; x++) { for (UInt z = 0; z < Chunk::Width; z++) { - for (UInt y = Chunk::Height; y > 1; y--) { + for (UInt y = Chunk::Height - 1; y != 0; y--) { Pos pos{x, y, z}; if (!is_valid_position(pos)) continue; @@ -96,4 +96,16 @@ Bool TreeDecorator::is_valid_position(Vector<3, UInt> pos) { && pos.z() + tree_radius <= Chunk::Width; } +void DefaultLightDecorator::decorate_chunk(Chunk& chunk) { + for (UInt x = 0; x < Chunk::Width; x++) { + for (UInt z = 0; z < Chunk::Width; z++) { + for (UInt y = Chunk::Height - 1; y != 0; y--) { + auto& block = chunk.at(x, y, z); + if (!block.type.is_translucent()) break; + chunk.at(x, y, z).light = 200; + } + } + } +} + } |
