Jondolf / avian

ECS-driven 2D and 3D physics engine for the Bevy game engine.
https://crates.io/crates/avian3d
Apache License 2.0
1.35k stars 108 forks source link

Determinism with contacts #406

Closed cBournhonesque closed 2 weeks ago

cBournhonesque commented 2 months ago

My networking crate had 0 rollbacks with xpbd, but now in one of my examples, everytime the entity collides with something else I have some rollbacks.

I checked the logs, it seems like my inputs are networked correctly, but I notice that after contacts the server and client entities have slightly different positions/rotations. It could still be a problem on my part but I think it's still useful to raise the issue just in case.

This happens even in singlethreaded mode

cBournhonesque commented 1 month ago

This might be related to the order of entities in the BroadPhase. Currently they are sorted by Entity, which might not be in the same order in a different World

cBournhonesque commented 1 month ago
image
cBournhonesque commented 1 month ago

Ok I tested it, I have 0 rollbacks anymore if I remove the entity-based sorting in BroadPhase and use the aabb.min.x based sorting