summary refs log tree commit diff
path: root/src/World/Generation/Lighting.cpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2023-07-21 02:17:03 +0200
committerMel <einebeere@gmail.com>2023-07-21 02:17:03 +0200
commit23d88e5f1c8f0c8652a07050fcfa8ff126e85d4a (patch)
treed2979c12a9675885b7ed969d5f51dbd69d969286 /src/World/Generation/Lighting.cpp
parentc0556f76fc5c8271c2eaa7ca91ad1c92c691d8bc (diff)
downloadmeowcraft-23d88e5f1c8f0c8652a07050fcfa8ff126e85d4a.tar.zst
meowcraft-23d88e5f1c8f0c8652a07050fcfa8ff126e85d4a.zip
Extremely simple chunk-limited lighting
Diffstat (limited to 'src/World/Generation/Lighting.cpp')
-rw-r--r--src/World/Generation/Lighting.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/World/Generation/Lighting.cpp b/src/World/Generation/Lighting.cpp
new file mode 100644
index 0000000..8df6e2a
--- /dev/null
+++ b/src/World/Generation/Lighting.cpp
@@ -0,0 +1,20 @@
+#include "Lighting.hpp"
+
+namespace MC::World::Generation::Lighting {
+
+void light_chunk(Chunk& chunk, ChunkNeighbors& _) {
+    for (UInt x = 0; x < Chunk::Width; x++) {
+        for (UInt z = 0; z < Chunk::Width; z++) {
+            U8 current_light_exposure = LightSun;
+            for (UInt y = Chunk::Height - 1; y != 0; y--) {
+                auto& block = chunk.at(x, y, z);
+                if (!block.type.is_translucent()) break;
+
+                current_light_exposure = (Real)current_light_exposure * (1 - block.type.opacity());
+                block.light = current_light_exposure;
+            }
+        }
+    }
+}
+
+}