diff --git a/crates/engine/src/tests/robustness.rs b/crates/engine/src/tests/robustness.rs
index dff5b6130..ca302cfc8 100644
--- a/crates/engine/src/tests/robustness.rs
+++ b/crates/engine/src/tests/robustness.rs
@@ -300,28 +300,32 @@ fn fillet_into_an_earlier_round() {
}
/// Clean seeds (seed 16: a partial face contact, fused), and the original seed 5 edge contact,
-/// now rejected without distortion.
+/// kept as two bodies without distortion.
#[test]
fn fixed_seeds_run_clean() {
for seed in FIXED_SEEDS {
if *seed == 5 {
- // Seed 5 originally joined these boxes along only an edge. Accepting
- // it required silently shifting the tool; that is now invalid input.
+ // Seed 5 originally joined these boxes along only an edge. Accepting it once required
+ // silently shifting the tool; since 94ee28d5c ("a join keeps solids that only touch as
+ // separate bodies") the join keeps the new box a body of its own and says why, as
+ // `join_touching_along_an_edge_keeps_a_separate_body` asserts in tests.rs.
let mut s = Session::default();
run(&mut s, "solid.box", json!({"length": 25, "width": 15, "height": 10}));
- let error = s
- .execute(
- "solid.box",
- &json!({
- "corner": [25, 2.5, 10], "length": 17.5, "width": 17.5,
- "height": 20, "operation": "join"
- }),
- )
- .unwrap_err();
- assert!(error.to_string().contains("zero-thickness edge contact"), "{error}");
- assert!((total_volume(&s) - 3750.0).abs() < 1e-6);
- assert_eq!(s.model.state().bodies.len(), 1);
- assert!(s.model.state().bodies.first().unwrap().body.validity().is_empty());
+ let r = run(
+ &mut s,
+ "solid.box",
+ json!({
+ "corner": [25, 2.5, 10], "length": 17.5, "width": 17.5,
+ "height": 20, "operation": "join"
+ }),
+ );
+ assert_eq!(r["notice"]["contact"], "along_edge", "{r}");
+ // 25 x 15 x 10 and 17.5 x 17.5 x 20, unmoved and sharing no volume.
+ assert!((total_volume(&s) - (3750.0 + 6125.0)).abs() < 1e-6, "{}", total_volume(&s));
+ assert_eq!(s.model.state().bodies.len(), 2);
+ for b in &s.model.state().bodies {
+ assert!(b.body.validity().is_empty(), "{}: {:?}", b.name, b.body.validity());
+ }
continue;
}
if *seed == 16 {
diff --git a/crates/kernel/src/mesh_convert.rs b/crates/kernel/src/mesh_convert.rs
index 6a062f97a..e5cf84141 100644
--- a/crates/kernel/src/mesh_convert.rs
+++ b/crates/kernel/src/mesh_convert.rs
@@ -49,6 +49,7 @@ pub fn convert_prismatic_mesh(body: &Body, tolerance: f64) -> Result
{
return Err(invalid("triangle refers to a missing vertex"));
};
let cross = (*pb - *pa).cross(*pc - *pa);
+ // `weld` dropped the triangles of no area, so none is left here.
let Some(mut n) = cross.normalized() else { return Err(invalid("degenerate triangle")) };
for (a, b) in [(a, b), (b, c), (c, a)] {
let entry = edges.entry((a.min(b), a.max(b))).or_default();
@@ -126,17 +127,39 @@ fn weld(mesh: &crate::meshbody::TriMesh, tolerance: f64) -> Result {
};
remap.push(i);
}
- let triangles = mesh
- .triangles
- .iter()
- .map(|t| {
- let (Some(&a), Some(&b), Some(&c)) = (remap.get(t[0] as usize), remap.get(t[1] as usize), remap.get(t[2] as usize)) else {
- return Err(invalid("missing triangle vertex"));
- };
- Ok([a, b, c])
- })
- .collect::>>()?;
- crate::mesh_body(&positions, &triangles)
+ // A triangle of no area (its corners on one line, or welded into one another) adds no
+ // surface, so it is dropped rather than refused (#4561); the closed-manifold check that
+ // follows still refuses a mesh that needed it to close. Only the vertices the kept triangles
+ // use stay, so a dropped triangle's corner cannot widen the part's extent.
+ let mut used: Vec