changes to binary transparency meshing

This commit is contained in:
griffi-gh 2023-02-18 01:04:54 +01:00
parent fc783d52dc
commit ce687e8d36
3 changed files with 11 additions and 3 deletions

View file

@ -124,7 +124,7 @@ impl Block {
name: "water", name: "water",
render: RenderType::BinaryTransparency(CubeTexture::all(BlockTexture::WaterSolid)), render: RenderType::BinaryTransparency(CubeTexture::all(BlockTexture::WaterSolid)),
collision: CollisionType::None, collision: CollisionType::None,
raycast_collision: false, raycast_collision: true,
}, },
} }
} }

View file

@ -24,6 +24,7 @@ const BLOCK_KEY_MAP: &[(VirtualKeyCode, Block)] = &[
(VirtualKeyCode::Key5, Block::Sand), (VirtualKeyCode::Key5, Block::Sand),
(VirtualKeyCode::Key6, Block::Stone), (VirtualKeyCode::Key6, Block::Stone),
(VirtualKeyCode::Key7, Block::Torch), (VirtualKeyCode::Key7, Block::Torch),
(VirtualKeyCode::Key8, Block::Leaf),
]; ];
fn pick_block_with_number_keys( fn pick_block_with_number_keys(

View file

@ -43,10 +43,17 @@ pub fn generate_mesh(data: MeshGenData) -> (Vec<ChunkVertex>, Vec<u32>) {
for face in CubeFace::iter() { for face in CubeFace::iter() {
let facing_direction = face.normal(); let facing_direction = face.normal();
let facing_coord = coord + facing_direction; 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 { let face_obstructed = match descriptor.render {
RenderType::SolidBlock(_) => matches!(facing_descriptor.render, RenderType::SolidBlock(_)), 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!(), _ => unreachable!(),
}; };
if !face_obstructed { if !face_obstructed {