dimforge / rapier

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

Clarification on Determinism #562

Closed DavidEichmann closed 6 months ago

DavidEichmann commented 7 months ago

The docs assert that cross platform determinism is supported. Great! But looking into this I wonder if that's really true. How is floating point (FP) determinism achieved? Consider the following:

DavidEichmann commented 6 months ago

After a little digging my guess is that you use a pinned version of libm (rust port) and hope that this provides determinism, which is not entirely unreasonable. I assume rapier has some mechanism to ensure libm functions are used rather that std functions (I'm not sure how to achieve that other than wrapping all float types in a libm-float type).

DavidEichmann commented 6 months ago

...Indeed it seems the ComplexField trait is used to force libm usage e.g. here