Function nearest_hit_among

Source
pub fn nearest_hit_among(
    mesh: &impl TriangleMeshView,
    ray: &Ray3,
    tolerance: Tolerance,
    candidates: impl IntoIterator<Item = usize>,
) -> Result<Option<RayHit3>, RayMeshError>
Expand description

Nearest hit over caller-supplied candidate triangles.

This is the composition point with a broad phase: feed it the triangle indices a BVH walk produced. Candidates may repeat and may arrive in any order; the result does not depend on that order. A candidate index at or beyond mesh.triangle_count() is refused with RayMeshError::TriangleIndexOutOfRange, and a triangle that references a missing position with RayMeshError::PositionIndexOutOfRange.

ยงDeterminism

Hits are ordered by t, then by triangle index. Two coplanar triangles sharing an edge therefore resolve to the same triangle on every run and on every platform, instead of depending on traversal order.