INNER CODE UNIT · Rust
ground_under
dust-engine/dust · crates/character/src/lib.rs:338
fn ground_under(
move_and_slide: &MoveAndSlide,
position: Vec3,
character: &Character,
filter: &SpatialQueryFilter,
) -> bool {
let reach = character.height * 0.5 + character.step_height + character.ground_probe;
move_and_slide
.spatial_query
.cast_ray(position, Dir3::NEG_Y, reach, true, filter)
.is_some_and(|hit| hit.normal.y >= character.min_ground_normal_y)
}
/// Try the move again from `step_height` higher: sweep up, slide horizontally,
/// sweep back down. Accept it when the raised capsule has a full radius of room
/// ahead (a step, not a wall), lands on something, and ends up higher than it
/// started. The landing's contact normal is not consulted: the rounded bottom
/// first meets a ledge's front edge, whose normal tilts; `ground_under` then