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

Store local contact normals and transform them into world-space at each solve #97

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

Jondolf
Copy link
Owner

@Jondolf Jondolf commented Jul 26, 2023

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.

80_cube_stack

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!

…ints

The normals should be updated at every solve. This significantly reduces
positional drift.

The contact normals and contact points are now stored in local space,
and `ContactData` has helper methods for conversion to global space.
@Jondolf Jondolf added C-Enhancement New feature or request A-Dynamics Relates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so on labels Jul 26, 2023
@Jondolf Jondolf mentioned this pull request Jul 26, 2023
@Jondolf Jondolf merged commit 1bdede9 into main Jul 26, 2023
3 checks passed
@Jondolf Jondolf deleted the local-normals branch July 26, 2023 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Dynamics Relates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so on C-Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant