Skip to main content

ray_aabb_intersect

Function ray_aabb_intersect 

Source
pub fn ray_aabb_intersect(
    origin: Vector3D,
    dir: Vector3D,
    aabb_min: Vector3D,
    aabb_max: Vector3D,
) -> Option<(f64, f64, Vector3D)>
Expand description

Intersects a ray with an axis-aligned bounding box using the slab method.

§Arguments

  • Vector3D - The ray origin.
  • Vector3D - The ray direction (expected to be unit length).
  • Vector3D - The AABB minimum corner.
  • Vector3D - The AABB maximum corner.

§Returns

  • Option<(f64, f64, Vector3D)> - (t_near, t_far, normal) on hit, or None if the ray misses or is parallel to the slab.