-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.x] Fix physics BVH broadphase update when changing collision layer/mask #54108
[3.x] Fix physics BVH broadphase update when changing collision layer/mask #54108
Conversation
typename BVHTREE_CLASS::ItemExtra &exb = tree._extra[p_to.id()]; | ||
|
||
// if the userdata is the same, no collisions should occur | ||
if ((exa.userdata == exb.userdata) && exa.userdata) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lawnjelly I'm not 100% sure this condition is needed here, same with _handle_sort
above, but I've copied them from other functions that deal with pairing and it doesn't seem that it hurts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was something I had to copy from the original octree, there were some cases were duplicates were added by the client code, and they caused crashes if they collided with themselves. So it probably is safer to keep it in.
The BVH implementation is not checking collision layers on existing pairs on move like other physics broadphases do. This is solved by adding a new call to trigger pair callbacks again so the physics engine can check layers again (specific to the BVH version, other broadphase implementations just trigger a move like before).
5ef89fe
to
48144ed
Compare
Looks good in terms of the code, I just want to test it, couldn't download the artifacts for some reason so will have to build from source. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have now built it and it seems to work fine. Is maybe not as efficient as it can be but will do to fix it until we have a chance to do a bigger refactor. 👍
Thanks! |
The BVH implementation is not checking collision layers on existing pairs on move like other physics broadphases do.
This is solved by adding a new call to trigger pair callbacks again so the physics engine can check layers again (specific to the BVH version, other broadphase implementations just trigger a move like before).
It looks like a lot of file changes but active code changes are actually well contained to limit potential regressions.
Fixes #53997 for 3.4.
For 4.0 and 3.5, a cleaner approach will be used but it will be a wider change that will need more time for tests (see #53997 (comment)).