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
).
- Example 2D
- Example 3D
let point = point![1.0, 2.0];
let solid = true;
let filter = QueryFilter::default();
if let Some((handle, projection)) = query_pipeline.project_point(
rigid_body_set,
collider_set, &point, solid, filter
) {
// 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);
}
query_pipeline.intersections_with_point(
rigid_body_set, collider_set, &point, filter, |handle| {
// Callback called on each collider with a shape containing the point.
println!("The collider {:?} contains the point.", handle);
// Return `false` instead if we want to stop searching for other colliders containing this point.
true
}
);
let point = point![1.0, 2.0, 3.0];
let solid = true;
let filter = QueryFilter::default();
if let Some((handle, projection)) = query_pipeline.project_point(
rigid_body_set, &collider_set, &point, solid, filter
) {
// 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);
}
query_pipeline.intersections_with_point(
rigid_body_set, &collider_set, &point, filter, |handle| {
// Callback called on each collider with a shape containing the point.
println!("The collider {:?} contains the point.", handle);
// Return `false` instead if we want to stop searching for other colliders containing this point.
true
}
);
It is possible to only apply the scene query to a subsets of the colliders using a query filter