fix: axis or tangent plane on a drill tip no longer fails with "no face at NaN" (#567) (#655)

The nearest point on a triangle with a zero-length edge (a cone's tip) is no longer NaN, so an axis or tangent plane on a drill tip works again (#567).
This commit is contained in:
Lasse Lian authored and GitHub committed 2026-10-13 10:17:49 -04:00
1 parent 0e500cacd3
commit cb071bb93b
3 files changed
+75 -7

No files matched your search

+3 -2
View File
@@ -104,7 +104,8 @@ fn nearest_on_face(m: &Mesh, face: usize, p: Vec3) -> Option<(f64, Vec3)> {
let Some([a, b, c]) = m.tri(t) else { continue };
let q = closest(p, a, b, c);
let d = q.dist(p);
if best.is_none_or(|x| d < x.0) {
// A non-finite candidate must never become the best: nothing compares less than NaN.
if d.is_finite() && best.is_none_or(|x| d < x.0) {
best = Some((d, q));
}
}
@@ -317,7 +318,7 @@ fn legacy_locate<'a>(bodies: impl Iterator<Item = (usize, &'a ModelBody)>, name:
let Some([a, bb, c]) = m.tri(t) else { continue };
let q = closest(p, a, bb, c);
let d = q.dist(p) - if exact { 1e-9 } else { 0.0 };
if best.is_none_or(|x| d < x.0) {
if d.is_finite() && best.is_none_or(|x| d < x.0) {
best = Some((d, bi, *f as usize, q, !exact, tol));
}
}