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.intersect_point).
point = (1.0, 2.0, 3.0)
solid = True
max_dist = 12.0
query_filter = rp.QueryFilter()
query_pipeline = world.query_pipeline
projection = query_pipeline.project_point(point, solid, filter=query_filter, max_dist=max_dist)
if projection is not None:
handle, projection = projection
# The collider closest to the point has this `handle`.
print(f"Projected point on collider {handle}. Point projection: {projection.point}")
print(f"Point was inside of the collider shape: {projection.is_inside}")
def on_point_intersection(handle):
# Callback called on each collider with a shape containing the point.
print(f"The collider {handle} contains the point.")
return True # Return `False` to stop the search.
query_pipeline.intersect_point(point, on_point_intersection, filter=query_filter)
QueryPipeline.project_point returns None if no collider is closer than max_dist (which is unbounded if it isn't
given), and the handle of the collider the point was projected on, together with a PointProjection, otherwise. This
PointProjection contains the projected point (in world-space), and whether the original point was inside of that
collider (is_inside). If the point is inside of a shape, solid controls the result just like for
ray-casting: with solid set to True the point is its own projection, whereas
with solid set to False it is projected on the boundary of the shape. QueryPipeline.project_point_and_get_feature
also gives the FeatureId of the part of the shape (vertex, edge, or face) the point was projected on. Finally,
QueryPipeline.intersect_point calls the given function with the handle of each collider containing the point, until
this function returns False.
It is possible to only apply the scene query to a subsets of the colliders using a query filter