Skip to content

Commit

Permalink
Allow some floating point error when intersecting ray and triangle
Browse files Browse the repository at this point in the history
I don't know why this is now necessary, but we had some tests failing
on Xcode15 (CI was fine). I assume that something changed about how
AppleClang does floating point arithmetic, even though I can't find any
info on this. Anyway - allowing more floating point error works and
the tests are now fine.
  • Loading branch information
kduske committed Oct 24, 2023
1 parent cabf238 commit d522c97
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/vecmath/include/vecmath/intersection.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,24 +283,24 @@ constexpr T intersect_ray_triangle(
const auto q = cross(t, e1);

const auto u = dot(q, e2) / a;
if (u < T(0))
if (u < -constants<T>::almost_zero())
{
return nan<T>();
}

const auto v = dot(p, t) / a;
if (v < T(0))
if (v < -constants<T>::almost_zero())
{
return nan<T>();
}

const auto w = dot(q, d) / a;
if (w < T(0))
if (w < -constants<T>::almost_zero())
{
return nan<T>();
}

if (v + w > T(1.0))
if (v + w - T(1) > constants<T>::almost_zero())
{
return nan<T>();
}
Expand Down

0 comments on commit d522c97

Please sign in to comment.