You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Objective
Fixes#403.
#927 added `ColliderTrees` for the new BVH broad phase. We should reuse
them for spatial queries instead of maintaining and using a separate BVH
from Parry.
## Solution
In short:
- Add more traversal methods on `Bvh2` via extension traits (we should
probably upstream these)
- `sweep_traverse`, `sweep_traverse_miss`, `sweep_traverse_anyhit`, and
`sweep_traverse_dynamic`
- `squared_distance_traverse` and `squared_distance_traverse_dynamic`
- Add methods for BVH traversal on `ColliderTree`
- `ray_traverse_closest` and `ray_traverse_all`
- `sweep_traverse_closest` and `sweep_traverse_all`
- `squared_distance_traverse_closest`
- `point_traverse`
- `aabb_traverse`
- Remove `SpatialQueryPipeline`, and use the `ColliderTrees` traversal
methods for `SpatialQuery`
This involved some other miscellaneous changes:
- Shape casts now returns hits in arbitrary order when `max_hits > 1`,
similar to ray casts.
- `point2` and `normal2` were previously in local space, despite what
the docs state. They are now in world space.
## Testing
Tested different spatial queries in examples.
---
## Showcase
Before, updating the spatial query pipeline was extremely expensive for
large scenes with a lot of colliders:
<img width="263" height="439" alt="Before"
src="https://github.com/user-attachments/assets/0cc11950-cd69-434a-90f6-1fa517d255f9"
/>
(note that the tree optimization cost is partially hidden here, as it is
run in parallel with the spatial query pipeline update)
Now, using the much more optimized `ColliderTrees`, that overhead is
gone:
<img width="263" height="439" alt="After"
src="https://github.com/user-attachments/assets/e39091f1-3a6f-4cfd-b22d-c8ac9c646b5f"
/>
## Future Work
- Generic collider types for spatial queries (#810)
0 commit comments