summary refs log tree commit diff
path: root/src/World/Generation
diff options
context:
space:
mode:
Diffstat (limited to 'src/World/Generation')
-rw-r--r--src/World/Generation/Decoration.cpp14
-rw-r--r--src/World/Generation/Decoration.hpp5
-rw-r--r--src/World/Generation/Generator.cpp1
-rw-r--r--src/World/Generation/Generator.hpp1
4 files changed, 20 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;
+            }
+        }
+    }
+}
+
 }
diff --git a/src/World/Generation/Decoration.hpp b/src/World/Generation/Decoration.hpp
index b7a839b..2f119ff 100644
--- a/src/World/Generation/Decoration.hpp
+++ b/src/World/Generation/Decoration.hpp
@@ -31,4 +31,9 @@ private:
     Math::Random::Noise<2> m_tree_noise;
 };
 
+class DefaultLightDecorator final : public Decorator {
+public:
+    void decorate_chunk(Chunk& chunk) override;
+};
+
 }
diff --git a/src/World/Generation/Generator.cpp b/src/World/Generation/Generator.cpp
index 9d63fc1..79c10b6 100644
--- a/src/World/Generation/Generator.cpp
+++ b/src/World/Generation/Generator.cpp
@@ -126,6 +126,7 @@ Generator::Map3D<Bool> Generator::generate_terrain(Map2D<Real>& height_map, I64
 }
 
 void Generator::decorate_soil(Chunk& chunk, Map2D<BiomeType>& biome_map, Map3D<Bool>& terrain_map) {
+    // TODO: Put all of this into decorators.
     constexpr UInt dirt_depth = 4;
     constexpr UInt water_height = 40;
 
diff --git a/src/World/Generation/Generator.hpp b/src/World/Generation/Generator.hpp
index ee78dc5..85f2c38 100644
--- a/src/World/Generation/Generator.hpp
+++ b/src/World/Generation/Generator.hpp
@@ -45,6 +45,7 @@ private:
 
     static inline std::vector<Decorator*> s_decorators = {
         new TreeDecorator(),
+        new DefaultLightDecorator(),
     };
 
     Math::Perlin::Noise<2> m_landmass_noise{.scale=800.0f, .octaves=4, .persistence=0.3f, .lacunarity=3.5f};