dimforge / rapier

2D and 3D physics engines focused on performance.
https://rapier.rs
Apache License 2.0
3.77k stars 235 forks source link

Perfectly elastic objects gain energy with TGS soft in Newton's cradle example #630

Closed Jondolf closed 1 month ago

Jondolf commented 1 month ago

The Newton's cradle example seems to gain energy over time with the TGS soft solver. The balls have a coefficient of restitution of 1.

https://github.com/dimforge/rapier/assets/57632562/f140e9fd-68af-441e-a946-d46ff2dbf5b9

Increasing the number of iterations doesn't help much, as the same occurs when using 40 solver iterations. However, the legacy PGS solver behaves significantly better. So the new solver appears to have a restitution regression.

https://github.com/dimforge/rapier/assets/57632562/aea97002-389b-41c6-ae90-90ec0acafe37

This is on the master branch, with untouched default parameters.

Of course, it's worth noting that a Newton's cradle might not be the best stability or robustness test, and results can vary greatly depending on the setup and how large the gap between the balls is. But it might still be worth looking into considering they gain energy so easily here.

Vrixyz commented 1 month ago

Thanks for your vigilance ! This behaviour has been fixed/mitigated by https://github.com/dimforge/rapier/pull/635 ; the culprit was mostly the configuration for depenetration.