A hole placed on the side of a cone with no direction drilled along the nearest display-mesh triangle's normal, up to 2.6° off the surface's normal and sideways. Planes, cylinders and spheres already gave their exact normal; cones and tori now do too, from the surface the kernel reports for the face. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f484457c3b
commit
9b431fea16
2 files changed
+26
No files matched your search
@@ -3986,6 +3986,18 @@ fn faces_through(st: &ModelState, p: Vec3, reach: f64) -> Vec<(f64, Vec3, Option
|
||||
((v - axis * v.dot(axis)).normalized(), None)
|
||||
}
|
||||
Some(kernel::FaceSurface::Sphere { center, .. }) => ((p - center).normalized(), None),
|
||||
// Square to the line through the apex, not the nearest facet's normal (#10698).
|
||||
Some(kernel::FaceSurface::Cone { apex, axis, half_angle }) => {
|
||||
let v = p - apex;
|
||||
let out = (v - axis * v.dot(axis)).normalized();
|
||||
(out.and_then(|u| (u * half_angle.cos() - axis * half_angle.sin()).normalized()), None)
|
||||
}
|
||||
// Away from the nearest point of the ring the tube goes round.
|
||||
Some(kernel::FaceSurface::Torus { center, axis, major, .. }) => {
|
||||
let v = p - center;
|
||||
let ring = (v - axis * v.dot(axis)).normalized().map(|u| center + u * major);
|
||||
(ring.and_then(|q| (p - q).normalized()), None)
|
||||
}
|
||||
_ => (None, None),
|
||||
};
|
||||
let n = match exact {
|
||||
|
||||
@@ -856,3 +856,17 @@ fn recessed_drill_point_through_and_exact_shoulder_keep_the_existing_exit() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A hole on the side of a cone, given no direction, drills along the cone's normal there, not
|
||||
/// the nearest mesh facet's, which leaned it up to 2.6° sideways (#10698).
|
||||
#[test]
|
||||
fn a_hole_on_a_cones_side_drills_along_its_normal() {
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "solid.cone", json!({"radius": 15, "height": 20, "body_name": "Cone"})).unwrap();
|
||||
// The side is r = 15 (1 - z / 20): at (7.5, 0, 10) the outward normal is (0.8, 0, 0.6).
|
||||
run(&mut s, "solid.hole", json!({"position": [7.5, 0, 10], "diameter": 4, "depth": 4, "name": "H"})).unwrap();
|
||||
let f = s.doc.find_feature("H").unwrap();
|
||||
let solidcraft_doc::FeatureKind::Hole { direction, .. } = &f.kind else { panic!("not a hole") };
|
||||
let d = direction.0;
|
||||
assert!((d.x + 0.8).abs() < 1e-6 && d.y.abs() < 1e-6 && (d.z + 0.6).abs() < 1e-6, "{d:?}");
|
||||
}
|
||||
Reference in new issue
Block a user