We noticed an issue where the Collisions were using the order of Entity directly to sort the pair of entities in a contact.
The issue is that for networking, there is no guarantee that the pair of Entities that are replicated between a Client and a Server world are in the same direction.
Solution
A solution is to keep using the aabb.min.x to order the two entities.
There are a couple concerns:
we want to make sure that when we match with previous entity pairs, this is not an issue.
we want to make sure that this doesn't change how CollisionStarted and CollisionEnded events are sent, even if the entities change their order during a contact. we should probably add a test for this
it should be fined because those events are based on the Contacts struct that is generated during the narrow phase, and we made sure that contact matching still works independently of past entity order
Test
tested in lightyear that the simulations are now completely deterministic
probably need to test that contact matching works correctly, even if the aabb.min.x of the two entities gets swapped during the contact
Objective
We noticed an issue where the Collisions were using the order of
Entity
directly to sort the pair of entities in a contact. The issue is that for networking, there is no guarantee that the pair of Entities that are replicated between a Client and a Server world are in the same direction.Solution
aabb.min.x
to order the two entities.previous_contacts
here: https://github.com/cBournhonesque/avian/blob/ac1fd0269e04f19f6892c62019cbb9ad9c19444e/src/collision/narrow_phase.rs#L549 because we check both directionsmatch_manifolds
here: https://github.com/cBournhonesque/avian/blob/ac1fd0269e04f19f6892c62019cbb9ad9c19444e/src/collision/narrow_phase.rs#L571 which is why we modify the functionCollisionStarted
andCollisionEnded
events are sent, even if the entities change their order during a contact. we should probably add a test for thisContacts
struct that is generated during the narrow phase, and we made sure that contact matching still works independently of past entity orderTest
aabb.min.x
of the two entities gets swapped during the contact