Skip to main content

raycast

Function raycast 

Source
pub fn raycast(
    mesh: &Mesh,
    bvh: &Bvh,
    ray: &Ray,
    opts: &RayOptions,
) -> Result<Option<RayHit>>
Expand description

The nearest hit with opts.min_t <= t <= opts.max_t, or None. Equal t goes to the smallest triangle id, so the result is deterministic.

A ray crossing an edge or vertex shared by several triangles hits all of them (the test is watertight); triangles with zero area are never hit.

ยงErrors

QueryError::InvalidInput for a non-finite origin, a zero or non-finite direction, or min_t or max_t that is NaN, or min_t greater than max_t; then QueryError::MeshMismatch or QueryError::StaleBvh when bvh does not match the current mesh.