bevy_xpbd
bevy_xpbd copied to clipboard
Optimize shapecasting with multiple hits
trafficstars
Currently, SpatialQuery::shape_hits and SpatialQuery::shape_hits_callback can compute multiple hits by performing multiple best-first traversals in a loop. At each iteration, the entity that was hit is added to the excluded entities so that it gets filtered in the next iteration.
This is inefficient. The methods should be changed to only traverse the QBVH acceleration structure once, potentially with a depth-first traversal like SpatialQuery::ray_hits and SpatialQuery::ray_hits_callback.