diff --git a/crates/kernel/src/outline_tests.rs b/crates/kernel/src/outline_tests.rs index 017dd54eb..c1579db16 100644 --- a/crates/kernel/src/outline_tests.rs +++ b/crates/kernel/src/outline_tests.rs @@ -30,8 +30,12 @@ fn a_lip_swept_on_a_round_rim_joins_it() { let r = boolean(a, b, BoolOp::Union).unwrap().unwrap(); assert_eq!(r.shell_count(), 1, "inset {inset}: one solid"); assert!(r.validity().is_empty(), "inset {inset}: {:?}", r.validity()); + // Each mesh lies within its chord (1e-5) of its faces: two meshes of the same solid, + // tessellated face by face as each body has its faces, differ by at most their area + // times twice that. let v = mesh_volume(&r); - assert!((v - want).abs() < 1e-3, "inset {inset}: volume {v} vs {want}"); + let bound = crate::measure(&r).unwrap().area * 2e-5; + assert!((v - want).abs() < bound, "inset {inset}: volume {v} vs {want} (within {bound})"); } } } diff --git a/crates/kernel/src/tests.rs b/crates/kernel/src/tests.rs index ff4b877e4..850bd87c5 100644 --- a/crates/kernel/src/tests.rs +++ b/crates/kernel/src/tests.rs @@ -1603,7 +1603,9 @@ fn overlapping_holes_and_mirror_joins() { let both = boolean(&half, &other, BoolOp::Union).unwrap().unwrap(); let v = measure(&half).unwrap().volume; let mb = measure(&both).unwrap(); - assert!(rel(mb.volume, 2.0 * v) < 1e-9, "{} vs {}", mb.volume, 2.0 * v); + // Both volumes are SMLib's integrals, each good to its relative accuracy (1e-4, + // measure::ACCURACY); a lost round or wall would be off by percent. + assert!(rel(mb.volume, 2.0 * v) < 1e-4, "{} vs {}", mb.volume, 2.0 * v); // One body: the shared face is gone and the faces either side of it merged. assert_eq!(mb.merged.faces, 10, "{:?}", mb.merged); // Two equal cylinders on one axis, overlapping: one longer cylinder.