Add the ability to modify the contact points seen by the constraints solver #120
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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 thePhysicsPipeline::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 callingColliderBuilder::modify_solver_contacts(true)
on the relevant colliders. The latter option will be slightly more efficient.Fix #24