By default, Rapier is locally deterministic, meaning that running the exact same simulation (with the same initial conditions) twice with the same machine, using the same version of Rapier, and the same version of the Rust compiler, will result in the exact same simulation results. However, doing this on two different computers may result in completely different results.
Two simulations run with the same initial conditions if all the simulation structures are initialized with the same values, rigid-bodies/colliders/joints are constructed the same way, and they are added/removed to sets (rigid-body sets, etc.) in the exact same order.
It is possible to make Rapier cross-platform deterministic, meaning that running a simulation with two different computers (including different OS and/or different processors) will result in the exact same results. In order to achieve this, both computers must start the simulation with the same initial conditions as discussed above, and the following additional conditions must be met:
enhanced-determinismfeature of Rapier is enabled. Note that the
enhanced-determinismfeature cannot be enabled at the same time as the
- The target platforms must strictly comply to the IEEE 754-2008 floating-points standard. This ensures that floating-point computations behave the same on all platforms. This include most modern mainstream processors as well as WASM targets.
- If some of the values used to initialized Rapier structures are computed using floating points functions (sin, cos, tan, etc.) other
than addition/subtraction/multiplication/division, then you need to make sure the functions being used originate from
nalgebra. For example, do
ComplexFieldis imported by
use nalgebra::ComplexField) instead of