Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pomme-client/src/world/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,29 @@ mod tests {
assert_eq!(light_props(BlockState::AIR).dampening, 0);
}

#[test]
fn can_occlude_follows_no_occlusion() {
setup();
for (name, occludes) in [
("copper_grate", false),
("waxed_oxidized_copper_grate", false),
("test_instance_block", false),
("glass", false),
("oak_leaves", false),
("ice", false),
("stone", true),
("packed_ice", true),
("blue_ice", true),
("copper_block", true),
] {
assert_eq!(
light_props(find_state(name, &[])).can_occlude,
occludes,
"{name}"
);
}
}

#[test]
fn slab_face_occlusion() {
setup();
Expand Down
22 changes: 2 additions & 20 deletions pomme-client/src/world/block/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,6 @@ pub struct BakedQuad {
pub struct BakedModel {
pub quads: Vec<BakedQuad>,
pub is_full_cube: bool,
/// Vanilla `canOcclude`: full cubes occlude, but cutout blocks like leaves
/// don't, so neighbor faces against them still render.
pub occludes: bool,
}

#[derive(Clone)]
Expand Down Expand Up @@ -456,12 +453,9 @@ pub fn bake_all_models(
&mut model_cache,
packs,
);
if let Some(mut baked) =
if let Some(baked) =
bake_resolved_model(&resolved, model_ref.x, model_ref.y, block_tint)
{
if is_non_occluding(block_name) {
baked.occludes = false;
}
variants_map.insert(variant_key.clone(), baked);
}
}
Expand Down Expand Up @@ -637,7 +631,6 @@ pub fn bake_item_models(
Some(mut model) => {
model.quads.extend(baked.quads);
model.is_full_cube = false;
model.occludes = false;
model
}
});
Expand Down Expand Up @@ -774,7 +767,6 @@ fn bake_chest_item_model(gui: DisplayTransform, gui_light: GuiLight) -> BakedMod
BakedModel {
quads,
is_full_cube: false,
occludes: false,
}
}

Expand Down Expand Up @@ -1518,11 +1510,9 @@ fn bake_resolved_model(
return None;
}

let is_full_cube = check_full_cube(&quads);
Some(BakedModel {
is_full_cube: check_full_cube(&quads),
quads,
is_full_cube,
occludes: is_full_cube,
})
}

Expand Down Expand Up @@ -1815,14 +1805,6 @@ fn face_textures_base(
None
}

/// Full-cube blocks that mustn't cull adjacent faces (vanilla `noOcclusion`).
/// Solid `packed_ice`/`blue_ice` still occlude, so `ice` is matched exactly.
fn is_non_occluding(block_name: &str) -> bool {
block_name.ends_with("_leaves")
|| block_name.ends_with("_stained_glass")
|| matches!(block_name, "glass" | "tinted_glass" | "ice" | "frosted_ice")
}

fn determine_tint(block_name: &str) -> Tint {
if block_name == "redstone_wire" {
Tint::Redstone
Expand Down
16 changes: 4 additions & 12 deletions pomme-client/src/world/block/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,22 +217,14 @@ impl BlockRegistry {
if quads.is_empty() { None } else { Some(quads) }
}

fn baked_model_flag(&self, state: BlockState, f: impl Fn(&BakedModel) -> bool) -> bool {
if super::is_air(state) {
return false;
}
self.get_baked_model(state).map(f).unwrap_or(false)
}

pub fn is_opaque_full_cube(&self, state: BlockState) -> bool {
self.baked_model_flag(state, |m| m.is_full_cube)
!super::is_air(state) && self.get_baked_model(state).is_some_and(|m| m.is_full_cube)
}

/// Whether `state` culls a neighbor's adjacent face. Unlike
/// [`Self::is_opaque_full_cube`], non-occluding blocks like leaves return
/// false even though they bake as full cubes.
/// Whether `state` culls a neighbor's adjacent face: a full cube that can
/// occlude, so `noOcclusion` cubes like glass and leaves don't.
pub fn occludes_neighbor(&self, state: BlockState) -> bool {
self.baked_model_flag(state, |m| m.occludes)
self.is_opaque_full_cube(state) && super::light_props(state).can_occlude
}

pub fn texture_names(&self) -> impl Iterator<Item = &str> + '_ {
Expand Down
Loading