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/Generator.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/World/Generation/Generator.cpp') diff --git a/src/World/Generation/Generator.cpp b/src/World/Generation/Generator.cpp index 88e69a7..9d63fc1 100644 --- a/src/World/Generation/Generator.cpp +++ b/src/World/Generation/Generator.cpp @@ -24,7 +24,7 @@ Chunk Generator::generate(I64 chunk_x, I64 chunk_y) { } #define SIMPLE_MAP_GENERATOR(name, getter) \ -Generator::Map2D Generator::name(I64 chunk_x, I64 chunk_y) { \ +Generator::Map2D Generator::name(I64 chunk_x, I64 chunk_y) { \ Matrix map{}; \ for (UInt x = 0; x < Chunk::Width; x++) { \ for (UInt y = 0; y < Chunk::Width; y++) { \ @@ -161,19 +161,20 @@ void Generator::decorate_soil(Chunk& chunk, Map2D& biome_map, Map3D 0; y--) { + auto& place = chunk.at(x, y, z); auto block = terrain_map(x, y, z); if (block) { if (column_depth == 0 && y >= water_height - 1) { - chunk.set(x, y, z, {top_block}); + place = {top_block}; } else if (column_depth < dirt_depth) { - chunk.set(x, y, z, {soil_block}); + place = {soil_block}; } else { - chunk.set(x, y, z, {BlockType::Stone}); + place = {BlockType::Stone}; } column_depth++; } else { if (y < water_height) { - chunk.set(x, y, z, {BlockType::Water}); + place = {BlockType::Water}; } column_depth = 0; } @@ -181,7 +182,7 @@ void Generator::decorate_soil(Chunk& chunk, Map2D& biome_map, Map3Ddecorate_chunk(chunk); } } -- cgit 1.4.1