summary refs log tree commit diff
path: root/src/World
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2023-07-08 01:20:53 +0200
committerMel <einebeere@gmail.com>2023-07-08 01:20:53 +0200
commit41fbca10f6c6cdd9c1623f1347e7ecb40f5e7f59 (patch)
tree7a41651c7c1eeecfc422395cbdb4b26ac619eaf9 /src/World
parentf8c0fb7e5d4cd0139b2b287980149eca688803bd (diff)
downloadmeowcraft-41fbca10f6c6cdd9c1623f1347e7ecb40f5e7f59.tar.zst
meowcraft-41fbca10f6c6cdd9c1623f1347e7ecb40f5e7f59.zip
Add crude texture transparency
Diffstat (limited to 'src/World')
-rw-r--r--src/World/BlockType.hpp12
-rw-r--r--src/World/Generation/ChunkMeshing.cpp6
2 files changed, 13 insertions, 5 deletions
diff --git a/src/World/BlockType.hpp b/src/World/BlockType.hpp
index 472523f..82c63d3 100644
--- a/src/World/BlockType.hpp
+++ b/src/World/BlockType.hpp
@@ -26,6 +26,16 @@ public:
 
     operator Value() const { return m_block; }
 
+    bool is_transparent() const {
+        switch (m_block) {
+        case Air:
+        case Leaves:
+            return true;
+        default:
+            return false;
+        }
+    }
+
     static std::vector<BlockType> all() {
         return {
             Air,
@@ -34,6 +44,8 @@ public:
             Stone,
             Sand,
             Snow,
+            Wood,
+            Leaves,
             Water,
         };
     }
diff --git a/src/World/Generation/ChunkMeshing.cpp b/src/World/Generation/ChunkMeshing.cpp
index 0494da4..e065987 100644
--- a/src/World/Generation/ChunkMeshing.cpp
+++ b/src/World/Generation/ChunkMeshing.cpp
@@ -129,11 +129,7 @@ bool is_face_visible(Chunk& chunk, const ChunkMeshing::ChunkNeighbors& neighbors
     }
 
     auto [neighbor] = chunk_to_ask->get(neighbor_pos.x(), neighbor_pos.y(), neighbor_pos.z());
-    if (neighbor == BlockType::Air) {
-        return true;
-    }
-
-    return false;
+    return neighbor.is_transparent();
 }
 
 GFX::Mesh ChunkMeshing::create_mesh_for_chunk(Chunk& chunk, const ChunkNeighbors& neighbors) {