Skip to content
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

Added user-implementable traits for collision/proximity pair filtering. #44

Merged
merged 4 commits into from
Oct 27, 2020

Conversation

sebcrozet
Copy link
Member

Fix #3
Fix #15

This PR adds two traits CollisionPairFilter and ProximityPairFilter that allows user-defined logic for determining if two colliders/sensors are allowed to interact, as discussed in #3

If these filters are set by the user (i.e. passed to the PhysicsPipeline::step method), then they replace the predefined filtering logic which consists of preventing contact computation between two non-dynamic bodies (the collision-groups on the other hands are still taken into account). That way, it is possible for the user to enable contacts and proximity between two non-dynamic bodies to be computed, as suggested in #15

Finally, the CollisionPairFilter returns a SolverFlags bitmask that will be used by the constraints solver to handle the contact manifolds for this collision pair. Currently, only one bit is implemented: SolverFlags::COMPUTE_IMPULSES. If this bit is set, then the constraints solver will compute impulses for the contact manifolds generated by this contact pair. If this bit is not set, these contact manifolds will be ignored by the constraints solver.

@sebcrozet sebcrozet added breaking change This will result in a breaking change enhancement New feature or request labels Oct 27, 2020
This is more consistent with the fact that the effect of collision groups is not overwritten either.
@sebcrozet
Copy link
Member Author

sebcrozet commented Oct 27, 2020

It looks like this PR introduces a performance regression for the case where objects have all fallen asleep:

image
image

Investigating that now.

Comment on lines 304 to 309
if (rb1.is_sleeping() || rb1.is_static()) && (rb2.is_sleeping() || rb2.is_static()) {
// No need to update this contact because nothing moved.
if (rb1.is_sleeping() && rb2.is_static()) || (rb2.is_sleeping() && rb1.is_static()) {
// No need to update this proximity because nothing moved.
return;
}
Copy link
Member Author

@sebcrozet sebcrozet Oct 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (and the similar test for contact computation) is the source of the performance regression when objects are resting.
With our change, two sleeping dynamic bodies will no longer be filtered-out by this test.

@sebcrozet
Copy link
Member Author

I fixed the regression:

image
image

This is ready to be merged now.

@sebcrozet sebcrozet merged commit e279c70 into master Oct 27, 2020
@sebcrozet sebcrozet deleted the custom_callbacks_filtering branch October 27, 2020 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This will result in a breaking change enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider allowing contacts between static/kinematic bodies. Add collision exceptions.
1 participant