Per-manifold material properties and tangent velocity #660
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.
Objective
Follow-up to #610.
Now that we have contact modification hooks, we should add support for modifying the surface properties of contacts. This can enable use cases like conveyor belts or non-uniform friction and restitution for different parts of a mesh.
Solution
Add
friction
,restitution
, andtangent_speed
/tangent_velocity
properties toContactManifold
. These are copied over for eachContactConstraint
.Note
Why not have a hook for modifying
ContactConstraint
directly instead?While we could technically do this right now, once we have wide SIMD constraints,
ContactConstraint
will also have its own SIMD version that is not as user-friendly and depends on feature flags. Providing hooks for modifying that is not very viable, and it would not be good for UX. Splitting contact modification into two hooks for different types of contact types could also be confusing for users.The new tangent velocity is a way to emulate relative movement of contact surfaces, which is often used for conveyor belts. A new
conveyor_belt
example has been added to demonstrate this.conveyor_belt.mp4
Engines like Rapier, Jolt, and Box2D also have tangent velocity and other material properties, but the capabilities for contact modification are different.
I opted for Jolt's approach of per-manifold configuration for now. It lets you have different material properties for e.g. different triangles of a trimesh, while keeping memory usage fairly minimal by not storing the properties for each individual contact point. I think this is a good balance of flexibility and cost.
If important use cases that require per-point surface properties arise, we could switch to that, but I'd prefer to keep things more simple and minimal for now.