Improvements to friction and restitution #551
Merged
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,
Friction
andRestitution
are 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
Friction
coefficients to0.5
Restitution
coefficient to0.0
CoefficientCombine::GeometricMean
as an optionFriction
andRestitution
DefaultFriction
andDefaultRestitution
resources, which are used for bodies with noFriction
orRestitution
specifiedMigration Guide
Friction
andRestitution
are no longer inserted automatically for rigid bodies. Instead, there are nowDefaultFriction
andDefaultRestitution
resources, which are used for bodies with noFriction
orRestitution
specified. 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.3
to0.5
.