|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
The triangle ray-crossing kernel. More...
Functions | |
| template<class V , class Source > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE V | crossing (const Source &a_triangle, const TriangleDistance::Vec3V< V > &a_origin, const TriangleDistance::Vec3V< V > &a_direction, const V a_tMin, const V a_tMax) noexcept |
| Where a ray crosses a triangle, or one triangle per lane (Möller–Trumbore). | |
The triangle ray-crossing kernel.
|
inlinenoexcept |
Where a ray crosses a triangle, or one triangle per lane (Möller–Trumbore).
The ray is origin + t * direction. A crossing counts where t is in [a_tMin, a_tMax], from either side of the triangle. The barycentric tests are widened by the rounding error of the crossing point, a distance of a few ulps of the ray origin's and the triangle's coordinates, so that a ray through an edge or vertex shared by two triangles crosses at least one of them however far it comes from; a ray in the triangle's plane does not cross it. A ray passing outside a triangle within that distance counts as crossing it (on the safe side, as a grazing marched ray does). The triangle is read through a_triangle, which provides vertex(k) for k = 0, 1, 2 as TriangleDistance::Vec3V<V> (see TriangleDistance::signedDistance()). For a SIMD::Pack every lane computes every test, so the kernel has no branches.
| V | Scalar (float or double) or SIMD::Pack. |
| Source | Triangle accessor. |
| [in] | a_triangle | Triangle accessor. |
| [in] | a_origin | Ray origin, the same in every lane. |
| [in] | a_direction | Ray direction, the same in every lane. |
| [in] | a_tMin | Start of the interval. |
| [in] | a_tMax | End of the interval. |