From 5f855bdaf1bebc70a48e6a7963428869f4c7184b Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Sat, 18 Feb 2023 01:04:54 +0100 Subject: [PATCH] changes to binary transparency meshing --- kubi-shared/src/block.rs | 2 +- kubi/src/block_placement.rs | 1 + kubi/src/world/mesh.rs | 11 +++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kubi-shared/src/block.rs b/kubi-shared/src/block.rs index c428078..5afc8db 100644 --- a/kubi-shared/src/block.rs +++ b/kubi-shared/src/block.rs @@ -124,7 +124,7 @@ impl Block { name: "water", render: RenderType::BinaryTransparency(CubeTexture::all(BlockTexture::WaterSolid)), collision: CollisionType::None, - raycast_collision: false, + raycast_collision: true, }, } } diff --git a/kubi/src/block_placement.rs b/kubi/src/block_placement.rs index 324a08c..19cfa8f 100644 --- a/kubi/src/block_placement.rs +++ b/kubi/src/block_placement.rs @@ -24,6 +24,7 @@ const BLOCK_KEY_MAP: &[(VirtualKeyCode, Block)] = &[ (VirtualKeyCode::Key5, Block::Sand), (VirtualKeyCode::Key6, Block::Stone), (VirtualKeyCode::Key7, Block::Torch), + (VirtualKeyCode::Key8, Block::Leaf), ]; fn pick_block_with_number_keys( diff --git a/kubi/src/world/mesh.rs b/kubi/src/world/mesh.rs index 93cd762..79c2aa7 100644 --- a/kubi/src/world/mesh.rs +++ b/kubi/src/world/mesh.rs @@ -43,10 +43,17 @@ pub fn generate_mesh(data: MeshGenData) -> (Vec, Vec) { for face in CubeFace::iter() { let facing_direction = face.normal(); let facing_coord = coord + facing_direction; - let facing_descriptor = get_block(facing_coord).descriptor(); + let facing_block = get_block(facing_coord); + let facing_descriptor = facing_block.descriptor(); let face_obstructed = match descriptor.render { RenderType::SolidBlock(_) => matches!(facing_descriptor.render, RenderType::SolidBlock(_)), - RenderType::BinaryTransparency(_) => matches!(facing_descriptor.render, RenderType::SolidBlock(_) | RenderType::BinaryTransparency(_)), + RenderType::BinaryTransparency(_) => { + match facing_descriptor.render { + RenderType::SolidBlock(_) => true, + RenderType::BinaryTransparency(_) => block == facing_block, + _ => false, + } + }, _ => unreachable!(), }; if !face_obstructed {