Store local contact normals and transform them into world-space at each solve #97
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.
Currently, contact normals are stored in world-space. However, the directions can slightly change during each constraint solve, which can cause positional drift.
This PR stores contact normals and contact points in local space and transforms them into world-space in each penetration constraint and the velocity solve.
ContactData
has helper methods for conversion to global space, although they require the rotation and/or position of the body.Stacking cubes is now much more stable. Below is a screenshot of an 80 cube stack, with f32 precision, with sleeping disabled, after nearly 5 minutes of simulation.
Previously, the same stack fell in about 3 seconds due to cubes moving sideways.
Note that perfectly stable stacks require a lot of substeps (I think I used 80 or 90 for the test), but now it should at least be possible to have stable stacks.
Thanks to felixbjorkeson for noticing this issue!