fix: 射线原点微偏移避免面上歧义
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user