From de16a6b99a8c8dc1394b6f566da6d92ec67d1508 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Thu, 29 Oct 2026 00:53:12 -0400 Subject: [PATCH] Kernel: a half turn's caps keep their roles when its end plane is its start plane efd0a577b kept the cap flatness tolerance under a quarter of the gap between parallel start and end planes. A half turn's end plane is its start plane: the gap is 0, the tolerance became 0 and neither cap was found, so m0-revolve-primitives' two flat ends could keep no sketch attachment (design_corpus every_flat_face_of_every_corpus_design_takes_an_attached_sketch). Only planes apart by more than rounding bound the tolerance; coinciding ones are told apart by the profile's edges, as before. Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/smlib_sweeps.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/kernel/src/smlib_sweeps.rs b/crates/kernel/src/smlib_sweeps.rs index 94cbe3406..679a3630c 100644 --- a/crates/kernel/src/smlib_sweeps.rs +++ b/crates/kernel/src/smlib_sweeps.rs @@ -275,8 +275,13 @@ mod imp { // A cap's points lie on its plane to the evaluation's precision. Sized to the body, the // flatness tolerance can exceed the gap between parallel start and end planes (a box // 0.1 µm thick in a 14 mm body), which would put each cap in both: it stays under a - // quarter of that gap. - let gap = end.filter(|e| e.normal().cross(start.normal()).len() < 1e-9).map_or(f64::INFINITY, |e| start.height(e.origin).abs()); + // quarter of that gap. Planes that coincide (the ends of a half turn) are told apart by + // the profile's edges instead. + let gap = end + .filter(|e| e.normal().cross(start.normal()).len() < 1e-9) + .map(|e| start.height(e.origin).abs()) + .filter(|g| *g > size * 1e-9) + .unwrap_or(f64::INFINITY); let flat_tol = (size * 1e-5 + 1e-9).min(0.25 * gap); let near = 3.0 * mesh_tol + flat_tol; let flat = |f: usize, pl: &Plane| {