pub fn intersect_triangle(
ray: &Ray,
vertices: [Vector3D; 3],
) -> Option<(f64, Vector3D)>Expand description
Intersects a ray with a triangle using the Moller-Trumbore algorithm.
The test is two-sided: a hit on either face counts, and the returned
normal is flipped when needed so that it always faces against the ray
direction, making back-face hits usable for shading. A ray parallel to
the triangle plane yields None.
The ray’s own t_min/t_max are deliberately not consulted: this free
function reports the raw distance along the ray however far away the
triangle is. Ray::intersect_triangle is the range-clamped variant and
the two must stay distinguishable at the call site.
§Arguments
&Ray- The ray whose origin and direction are tested; its parameter range is ignored.[Vector3D; 3]- The three triangle vertices in winding order.
§Returns
Option<(f64, Vector3D)>- The hit distance along the ray and the unit surface normal oriented against the ray direction, orNoneon miss.