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

Add the ability to modify the contact points seen by the constraints solver #120

Merged
merged 10 commits into from
Feb 24, 2021

Conversation

sebcrozet
Copy link
Member

@sebcrozet sebcrozet commented Feb 23, 2021

This adds the ability to modify the contact points after they are generated by the narrow-phase but before they are seen by the constraints solver. This allows the simulation of various interesting effects like conveyor belts and one-way platforms:

one-way-platforms

This can also be used for fine-grained friction and restitution coefficient modification (e.g. to simulate multiple materials on a single collider).

The contact manifold now contains a user-defined piece of data that can be updated by the contact modifier. This is useful to add some updates that depend on the previous state of the simulation (as needed by one-way platform).

The two traits for filtering intersection and contact pairs have been removed in favor of a single PhysicsHooks trait that combines contact filtering, proximity filtering, and contact modification. This will also allow use to add more hooks in the future without requiring no arguments to be passed to the PhysicsPipeline::step method. This is a breaking change.

In order to tell the narrow-phase that contacts must be changed the contact manifold to be modified must be given the SolverFlags::MODIFY_SOLVER_CONTACTS flags. This can be achieved either using the contact pair filtering function, or by calling ColliderBuilder::modify_solver_contacts(true) on the relevant colliders. The latter option will be slightly more efficient.

Fix #24

@sebcrozet sebcrozet added C-Enhancement New feature or request breaking change This will result in a breaking change labels Feb 23, 2021
@sebcrozet sebcrozet merged commit 649eba1 into master Feb 24, 2021
@sebcrozet sebcrozet deleted the contact_modification branch February 24, 2021 10:26
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 C-Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to cancel events or at least react before the collision physics occurs.
1 participant