pub fn check_clearance<T>(
world: &T,
shape: CharacterShape,
feet: Vec3,
membership_mask: u32,
max_candidates: usize,
) -> Result<Clearance, ClearanceError>Expand description
Check the current terrain for penetration at fixed feet coordinates, without
recovery, ground snap, support lookup or scratch allocation. Uses the same
shape/obstacle separation and filtering as the motor. Touching is clear, with
the existing 1e-5 penetration tolerance (no extra skin clearance).
max_candidates is in 0..=1_000_000, matching the motor’s upper bound.
Zero proves clearance only if no candidates are visited. Sensors and excluded
layers still consume the budget, as in movement queries. A complete query is
required before reporting a blocker; budget/obstacle errors take precedence.
The budget bounds candidate processing, not traversal inside Terrain::visit.
Terrain must obey its complete/current-pose visitation contract.
use ferravex_math::Vec3;
use ferravex_physics::character::{check_clearance, CharacterShape, ClearanceError, Obstacle};
let shape = CharacterShape::Capsule { radius: 0.3, height: 1.8 };
assert_eq!(check_clearance(&[][..], shape, Vec3::ZERO, u32::MAX, 0)?.candidates, 0);
let ceiling = Obstacle::cuboid(9, Vec3::Y * 1.7, Vec3::new(2., 0.1, 2.));
assert_eq!(check_clearance(&[ceiling][..], shape, Vec3::ZERO, u32::MAX, 1),
Err(ClearanceError::Blocked { obstacle: 9 }));