Skip to main content

scene_queries_point_projection

Point projection will either project a point on the closest collider of the scene (QueryPipeline::project_point), or will enumerate every collider containing given point (QueryPipeline::intersections_with_point).

let point = point![1.0, 2.0];
let solid = true;
let max_dist = 12.0;
let filter = QueryFilter::default();

let query_pipeline = broad_phase.as_query_pipeline(
narrow_phase.query_dispatcher(),
rigid_body_set,
collider_set,
filter,
);

if let Some((handle, projection)) = query_pipeline.project_point(
&point, max_dist, solid
) {
// The collider closest to the point has this `handle`.
println!("Projected point on collider {:?}. Point projection: {}", handle, projection.point);
println!("Point was inside of the collider shape: {}", projection.is_inside);
}

for (handle, _) in query_pipeline.intersect_point(point) {
// Callback called on each collider with a shape containing the point.
println!("The collider {:?} contains the point.", handle);
}

It is possible to only apply the scene query to a subsets of the colliders using a query filter