#[non_exhaustive]pub struct RayCastHit {
pub body: BodyId,
pub fraction: f32,
pub sub_shape_id: SubShapeId,
pub distance: f32,
pub normal: Vec3,
pub object_layer: ObjectLayer,
pub compound_child: Option<CompoundSubShape>,
}Expand description
The closest hit of a PhysicsWorld::cast_ray.
Convex shapes are solid: a ray that starts inside one hits it at fraction 0.0 exactly.
Triangle back faces are hit, so a heightfield is hit from below too.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.body: BodyIdThe body that was hit.
fraction: f32Fraction along the ray’s direction where it hit, in [0, 1].
sub_shape_id: SubShapeIdPath from the body’s shape to the leaf shape that was hit.
distance: f32Distance from the origin to the hit in metres: fraction times the direction’s length.
normal: Vec3Outward surface normal of the hit face in world space, unit length.
For a triangle hit from its back (a heightfield from below) it is still the face’s
normal, so it points away from the side the ray came from: normal . direction > 0.
For a ray that starts inside a convex shape (fraction == 0.0) it is the normal Jolt
computes at the origin, the normal of a nearby face with no unique meaning.
object_layer: ObjectLayerThe object layer of the hit body.
compound_child: Option<CompoundSubShape>The compound child that was hit, when the body’s shape is a compound.