Shapecast behavior and performance #481
BobbyAnguelov
started this conversation in
General
Replies: 1 comment 7 replies
-
I think it's very simple to implement the behavior that you want (I didn't make this the default behavior as people may actually want all those hits). Make a copy of
Note that mBroadPhase is PhysicsSystem::GetBroadPhaseQuery() and mBodyLockInterface is PhysicsSystem::GetBodyLockInterface() |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Me again (Sorry 😅)
I've been getting the shape cast queries integrated and hitting some issues. What I'm trying to do is to shapecast and return all shapes that I collide along the way, i.e. I treat all collisions as non-blocking (aka touches in physx). I'm using the all hit collector.
This results in the following result for a simple use case where I cast against 3 mesh shapes.
I get 405 hits (135 hits per shape) since Jolt is returning every hit per triangle per shape. I have ignore backfaces set, if I dont the hit count significantly climbs
With PhysX I get back only the closest hit per shape.
The physx behavior is kinda what I would expect in my use case since it is a sweep and not an overlap. IIRC havok and chaos will behave similarly in only returning the closest hit per shape. PhysX is also ~2X faster in performing the raw sweep ( 0.04ms vs 0.08ms for Jolt).
I've written a simple collector to track the closest hit per bodyID (see code below). This has no effect on the performance and gives me the expected result but it's still significantly slower than physx for the same query.
Additionally, I considered what you said in the filtering test with regards to how you dont really run such queries but you instead run multiple sequential sweeps. This feels like it would be significantly more expensive as I would need to repeat the same query over and over, adding a new body to ignore to the filter as well as shifting the starting location with each detected hit until there are no more hits.
As I mentioned, I'm not sure what benefit there is to returning every single hit for a sweep, and it feels like it can be significantly faster to just find the closest hit for a shape in place while walking the triangles of the shape and then just return that to the user. There are various avenues for optimizing that in place, I mean just avoiding 402 virtual function calls for one will provide a decent speedup. If the user REALLY wants to get all hits in special situations, they can simple just do an overlap with the hit body as a follow up or perhaps we can make that a setting on the filter just like the ignore back faces option?
What are your thoughts on this?
Beta Was this translation helpful? Give feedback.
All reactions