From 41fbca10f6c6cdd9c1623f1347e7ecb40f5e7f59 Mon Sep 17 00:00:00 2001 From: Mel Date: Sat, 8 Jul 2023 01:20:53 +0200 Subject: Add crude texture transparency --- src/World/BlockType.hpp | 12 ++++++++++++ src/World/Generation/ChunkMeshing.cpp | 6 +----- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src/World') 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 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) { -- cgit 1.4.1