Function navmap::ray_triangle_intersect

Function Documentation

inline bool navmap::ray_triangle_intersect(const Vec3 &orig, const Vec3 &dir, const Vec3 &v0, const Vec3 &v1, const Vec3 &v2, float &t, float &u, float &v)

Möller–Trumbore ray–triangle intersection.

Solves intersection between a ray (orig + t * dir, t > 0) and triangle (v0, v1, v2). Returns true on hit and outputs:

  • t: parametric distance along the ray (t > 0).

  • u, v: barycentric coordinates (with w = 1 - u - v).

Warning

Numerical robustness depends on the geometry scale; kEps is set conservatively for typical mapping units (meters).

Parameters:
  • origRay origin.

  • dirRay direction (not necessarily unit length).

  • v0 – First triangle vertex.

  • v1 – Second triangle vertex.

  • v2 – Third triangle vertex.

  • t – Output ray parameter on hit (> 0).

  • u – Output barycentric u on hit.

  • v – Output barycentric v on hit.

Returns:

True if the ray intersects the triangle with t > 0.