diff --git a/crates/doc/src/display_quality.rs b/crates/doc/src/display_quality.rs index 911cd8637d..1877eb82b4 100644 --- a/crates/doc/src/display_quality.rs +++ b/crates/doc/src/display_quality.rs @@ -176,7 +176,12 @@ mod tests { let sag = mesh .triangles .iter() - .map(|t| t.map(|i| mesh.positions[i as usize])) + .zip(&mesh.tri_face) + // The side wall's own triangles: the flat caps have corners on the rim too. + .filter(|(_, f)| { + matches!(solidcraft_kernel::face_surface(&mb.body, **f as usize), Some(solidcraft_kernel::FaceSurface::Cylinder { .. })) + }) + .map(|(t, _)| t.map(|i| mesh.positions[i as usize])) .filter(|t| t.iter().all(|p| (r(*p) - 20.0).abs() < 1e-9)) .map(|[a, b, c]| 20.0 - r((a + b + c) * (1.0 / 3.0))) .fold(0.0, f64::max); diff --git a/crates/ui-egui/src/display_lod.rs b/crates/ui-egui/src/display_lod.rs index 17a2f3f67e..aa2a988411 100644 --- a/crates/ui-egui/src/display_lod.rs +++ b/crates/ui-egui/src/display_lod.rs @@ -468,7 +468,15 @@ mod tests { let sag = mesh .triangles .iter() - .map(|t| t.map(|i| mesh.positions[i as usize])) + .zip(&mesh.tri_face) + // The side wall's own triangles: the flat caps have corners on the rim too. + .filter(|(_, f)| { + matches!( + solidcraft_engine::kernel::face_surface(&b.body, **f as usize), + Some(solidcraft_engine::kernel::FaceSurface::Cylinder { .. }) + ) + }) + .map(|(t, _)| t.map(|i| mesh.positions[i as usize])) .filter(|t| t.iter().all(|p| (r(*p) - 10.0).abs() < 1e-9)) .map(|[a, b, c]| 10.0 - r((a + b + c) * (1.0 / 3.0))) .fold(0.0, f64::max); diff --git a/crates/ui-egui/src/hole_placement_ui_tests.rs b/crates/ui-egui/src/hole_placement_ui_tests.rs index be1020d302..e3505cff1d 100644 --- a/crates/ui-egui/src/hole_placement_ui_tests.rs +++ b/crates/ui-egui/src/hole_placement_ui_tests.rs @@ -785,7 +785,8 @@ fn cylinder_with_cluster(sketch: Value, at: [f64; 2], view: &str) -> Cluster { gap.x.max(gap.y).max(gap.z) <= 1e-3 }; let (body_tris, face_tris, near_tris) = (m.triangles.len(), face.len(), face.iter().filter(|t| near_points(t)).count()); - assert!(body_tris >= 2 * face_tris, "the body has other faces: {body_tris} and {face_tris} triangles"); + // Other faces exist (the flat caps are two triangles each now, so the curved side can be most of the body). + assert!(body_tris > face_tris, "the body has other faces: {body_tris} and {face_tris} triangles"); Cluster { h, many, click, body_tris, face_tris, near_tris } }