feat: persistent islands + manifold reduction #895
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 PR adds contact manifold reduction, ensuring that each contact manifold only result in up to 4 solver contacts (in 3D). This simplifier the solver code further by ensuring a 1-to-1 matching between solver contact manifolds and contact constraints. Two manifold reductions strategies are implemented:
In practice, I selected the first approach as it appeared to work well with less operations than the more complex one. I’m keeping the second approach around for now for additional future experiments.
This PR also adds persistent islands. Instead of recalculating the simulation islands at each simulation step, both awake and sleeping islands are persisted across frames and updated incrementally. Whenever a rigid-body desires to sleep, it triggers (in some future frame) a connected-component traversal of the contact/joint graphs in order to attempt to extract a sleeping island.
In addition, an islands optimizer (that could use a bit more tuning) has been implemented to ensure (as long as it doesn’t affect correctness) that islands are neither too small nor too big. This results in generally better performances due to better cache utilisation. The island optimizer runs a small amount of work at each frame, progressively balancing the islands sizes.
The persistent islands optimization results in a performance improvement between 10% to 20% depending on the stress test. The graph below are examples of perf improvements (blue is current



master, red is this PR) on some of our stress tests (all_benchmarks3):