A vertex pick found its named edges and then picked each again by a point on it, among the edges of every body. At a corner where another body's edge runs past (a wall against a side wall), all three became that edge, and the vertex its end 3 mm away. Take each named edge's ends from the body that has it. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -215,10 +215,16 @@ fn named_vertex(st: &ModelState, at: Vec3, names: &[String]) -> Option<Vec3> {
|
||||
let ends: Vec<[Vec3; 2]> = names
|
||||
.iter()
|
||||
.map(|n| {
|
||||
// The edge with that name itself, never the one nearest the old pick.
|
||||
let on = bodies(st).find_map(|b| crate::naming::find_edge(b, n, at).ok())?.0;
|
||||
let pts = edge_points(st, on, &None).ok()?;
|
||||
Some([*pts.first()?, *pts.last()?])
|
||||
// The edge with that name itself, never the one nearest the old pick, and its ends
|
||||
// on the body that has it: picked again by a point on it, a corner found the first
|
||||
// edge of any body through that corner, such as another body's edge running past
|
||||
// it, so a vertex took that edge's end (#8650).
|
||||
bodies(st).find_map(|b| {
|
||||
let hit = crate::name_lookup::locate_edge(b, n, at).ok()?;
|
||||
let m = b.mesh();
|
||||
let pts = m.edges.get(hit.edge)?;
|
||||
Some([*pts.first()?, *pts.last()?])
|
||||
})
|
||||
})
|
||||
.collect::<Option<_>>()?;
|
||||
let (first, rest) = ends.split_first()?;
|
||||
|
||||
@@ -380,6 +380,29 @@ fn a_plane_through_three_vertices_follows_them() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A corner of one box where another box's edge runs past it, as where a wall meets the side
|
||||
/// wall it stands against (the render-studio example, #8650): the vertex stays that corner. Its
|
||||
/// edges were found by name and then picked again by a point, which took the first edge through
|
||||
/// the corner of any body, the side wall's, and so its end 3 mm away. Three such corners were
|
||||
/// "on one line".
|
||||
#[test]
|
||||
fn a_vertex_where_another_bodys_edge_runs_past_stays_its_corner() {
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "solid.box", json!({"corner": [29, -22, 4], "length": 3, "width": 44, "height": 19, "body_name": "Side"}));
|
||||
run(&mut s, "solid.box", json!({"corner": [-29, 19, 4], "length": 58, "width": 3, "height": 19, "body_name": "Back"}));
|
||||
run(&mut s, "construct.point.vertex", json!({"point": {"vertex": [29, 19, 23]}, "name": "P"}));
|
||||
assert!(near(point(&s, "P"), Vec3::new(29.0, 19.0, 23.0)), "{:?}", point(&s, "P"));
|
||||
run(
|
||||
&mut s,
|
||||
"construct.plane.three_points",
|
||||
json!({"a": {"vertex": [29, 22, 23]}, "b": {"vertex": [29, 22, 4]}, "c": {"vertex": [29, 19, 23]}, "name": "T"}),
|
||||
);
|
||||
let t = plane(&s, "T");
|
||||
for p in [Vec3::new(29.0, 22.0, 23.0), Vec3::new(29.0, 22.0, 4.0), Vec3::new(29.0, 19.0, 23.0)] {
|
||||
assert!(on_plane(&t, p), "{p:?} is off {t:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// In a component moved 50 mm along X, picks given in the world land on its geometry, and the
|
||||
/// axis and point move with the occurrence.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user