RayIntersection

Type Alias RayIntersection 

Source
pub type RayIntersection = RayIntersection;
Expand description

The intersection between a ray and a collider.

Aliased Type§

pub struct RayIntersection {
    pub time_of_impact: f32,
    pub normal: Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>,
    pub feature: FeatureId,
}

Fields§

§time_of_impact: f32

The time of impact (parameter t) where the ray hits the shape.

The exact hit point can be computed with ray.point_at(time_of_impact). If the ray direction is normalized, this represents the distance traveled.

§normal: Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>

The surface normal at the intersection point.

  • Typically points outward from the shape
  • May point inward if ray origin is inside a non-solid shape
  • May be unreliable if time_of_impact is exactly zero

Note: This should be a unit vector but is not enforced by the type system yet.

§feature: FeatureId

The geometric feature (vertex, edge, or face) that was hit.

This can be used for more detailed collision response or to identify exactly which part of the shape was struck.