Improvements to friction and restitution#551
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Fixes #503
Partially fixes #119
Currently,
FrictionandRestitutionare inserted automatically. Bodies are bouncy by default, with a coefficient of restitution of0.3. Coefficients of static and dynamic friction are also0.3.I gathered some default values used for coefficients and combine rules in other engines:
There's a lot of variation here, but everything except Avian defaults to zero restitution. It makes sense for bounciness to be opt-in, and it's good for performance. Friction also tends to be higher, and indeed Avian's default friction feels quite slidey.
Some engines also use a geometric mean
sqrt(a * b)for the friction combine rule, which we don't currently support.We should change to more sensible defaults, and also make the default values globally configurable, like in Unity. Different games have different needs and preferences, and it should be possible to use the best default that works for you.
Solution
Frictioncoefficients to0.5Restitutioncoefficient to0.0CoefficientCombine::GeometricMeanas an optionFrictionandRestitutionDefaultFrictionandDefaultRestitutionresources, which are used for bodies with noFrictionorRestitutionspecifiedMigration Guide
FrictionandRestitutionare no longer inserted automatically for rigid bodies. Instead, there are nowDefaultFrictionandDefaultRestitutionresources, which are used for bodies with noFrictionorRestitutionspecified. These resources can be configured to change the global defaults for friction and restitution.The default restitution is now
0.0, meaning that bodies are no longer bouncy by default. The default coefficients of friction have also been increased from0.3to0.5.