From e241978a15344c344fc12f22bede95cd4a28ec60 Mon Sep 17 00:00:00 2001 From: Brennen Herbruck Date: Sun, 8 Nov 2026 03:10:51 -0500 Subject: [PATCH] Tests: side-wall sag checks pick the wall by face, the dense-cluster test keeps its intent The flat caps of a cylinder are their rim alone now, so a triangle with all corners on the rim is no proof of a wall triangle: pick the wall's triangles by their face. The hole placement test asserted the body had twice the face's triangles; it asserts the body has other faces than the one picked. Co-Authored-By: Claude Opus 5.5 --- crates/doc/src/display_quality.rs | 7 ++++++- crates/ui-egui/src/display_lod.rs | 10 +++++++++- crates/ui-egui/src/hole_placement_ui_tests.rs | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) 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 } }