Function clip_aabb_line

Source
pub fn clip_aabb_line(
    aabb: &Aabb,
    origin: &Point<f32>,
    dir: &Vector<f32>,
) -> Option<((f32, Vector<f32>, isize), (f32, Vector<f32>, isize))>
Expand description

Computes the segment given by the intersection of a line and an Aabb.

Returns the two intersections represented as (t, normal, side) such that:

  • origin + dir * t gives the intersection points.
  • normal is the face normal at the intersection. This is equal to the zero vector if dir is invalid (a zero vector or NaN) and origin is inside the AABB.
  • side is the side of the AABB that was hit. This is an integer in [-3, 3] where 1 represents the +X axis, 2 the +Y axis, etc., and negative values represent the corresponding negative axis. The special value of 0 indicates that the provided dir is zero or NaN and the line origin is inside the AABB.