Skip to content

Contact listener guarantees about order of callbacks #1449

Answered by jrouwe
zopsicle asked this question in Q&A
Discussion options

You must be logged in to vote

Is it possible that, within an update, a pair of bodies both start colliding and stop colliding, but the contact listener receives the corresponding OnContactAdded and OnContactRemoved calls concurrently or out of order?

No, during a simulation step (parameter inCollisionSteps in PhysicsSystem::Update) you either get an OnContactAdded/Persisted or you get an OnContactRemoved callback for a contact, never both. If you passed inCollisionSteps > 1 then you can see an 'add' and a 'remove' during the same call to PhysicsSystem::Update but they will be ordered correctly (possibly called from different threads, with a memory barrier between the two calls).

Note that a contact is defined as (bo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by zopsicle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants