Demindiro / godot_rapier3d

Godot bindings for the Rapier3D physics engine
MIT License
43 stars 2 forks source link

Are we able to enable determinism? #20

Open ValorZard opened 3 years ago

ValorZard commented 3 years ago

Hello! I'm quite interested in working on a rollback netcode project using Rapier, since it has a deterministic component. Godot's own physics are not great for this, but apparently according to this person, they were able to get a similar effect by controlling Box2D. https://github.com/godotengine/godot-proposals/issues/2821#issuecomment-854124881 I was wondering if a similar effect could be enabled with this, especially if the determinism feature flag could be enabled.

Demindiro commented 3 years ago

To enable determinism you just need to replace the "simd-nightly" feature with "enhanced-determinism" in rapier3d/Cargo.toml.

For complete determinism serde-serialize or cloning the Space state may be necessary though simply saving & restoring state using GDScript may also be sufficient. It is likely that not all necessary info for full determinism is visible to the GDScript side though.

Manual stepping should be as simple as exposing the existing step method in Godot.

ValorZard commented 3 years ago

Thank you for the quick response! It would be really cool if we could get determinism working with godot, as it would allow for lockstep networking and rollback netcode solutions to both work. Right now, most rollback solutions rely on sending state, which isn't as efficent.