Browse Source

Updated documentation based on lessons learned in godotengine/godot#110757

Jorrit Rouwe 1 week ago
parent
commit
7778a66d20
1 changed files with 5 additions and 1 deletions
  1. 5 1
      Jolt/Physics/Collision/ContactListener.h

+ 5 - 1
Jolt/Physics/Collision/ContactListener.h

@@ -69,8 +69,12 @@ enum class ValidateResult
 /// Note that contact listener callbacks are called from multiple threads at the same time when all bodies are locked, this means you cannot
 /// Note that contact listener callbacks are called from multiple threads at the same time when all bodies are locked, this means you cannot
 /// use PhysicsSystem::GetBodyInterface / PhysicsSystem::GetBodyLockInterface but must use PhysicsSystem::GetBodyInterfaceNoLock / PhysicsSystem::GetBodyLockInterfaceNoLock instead.
 /// use PhysicsSystem::GetBodyInterface / PhysicsSystem::GetBodyLockInterface but must use PhysicsSystem::GetBodyInterfaceNoLock / PhysicsSystem::GetBodyLockInterfaceNoLock instead.
 /// If you use a locking interface, the simulation will deadlock. You're only allowed to read from the bodies and you can't change physics state.
 /// If you use a locking interface, the simulation will deadlock. You're only allowed to read from the bodies and you can't change physics state.
-///
 /// During OnContactRemoved you cannot access the bodies at all, see the comments at that function.
 /// During OnContactRemoved you cannot access the bodies at all, see the comments at that function.
+/// 
+/// While a callback can come from multiple threads, all callbacks relating to a single body pair are serialized.
+/// For EMotionQuality::Discrete bodies, during every 'collision step' in a PhysicsSystem::Update, you will receive at most one OnContactAdded/Persisted/Removed call per body/sub shape pair.
+/// For EMotionQuality::LinearCast bodies, you may get an OnContactAdded followed by an OnContactPersisted for the same body/sub shape pair.
+/// This happens when a body collides both in the discrete and the continuous collision detection stage.
 class ContactListener
 class ContactListener
 {
 {
 public:
 public: