diff --git a/src/boolean/boolean_mesh.cpp b/src/boolean/boolean_mesh.cpp index 51089ab..dfc6d28 100644 --- a/src/boolean/boolean_mesh.cpp +++ b/src/boolean/boolean_mesh.cpp @@ -86,7 +86,9 @@ bool is_point_inside_bvh(const core::Point3D& p, core::Vector3D dir(1.0, 0.371, 0.539); dir.normalize(); - Ray3Dd ray(p, dir); + // Offset origin slightly to avoid exactly-on-face ambiguity + core::Point3D origin = p + dir * 1e-6; + Ray3Dd ray(origin, dir); auto results = bvh.query_ray(ray); int hits = 0; for (const auto& tri : results) { @@ -96,7 +98,7 @@ bool is_point_inside_bvh(const core::Point3D& p, double a = e1.dot(h); if (std::abs(a) < 1e-12) continue; double f = 1.0 / a; - core::Vector3D s = p - tri.v(0); + core::Vector3D s = origin - tri.v(0); double u = f * s.dot(h); if (u < 0.0 || u > 1.0) continue; core::Vector3D q = s.cross(e1);