Forráskód Böngészése

bullet: Fix deadlock when contact added callback accesses certain data or executes bullet methods

Dakota Smith 2 éve
szülő
commit
3097d2637c
1 módosított fájl, 5 hozzáadás és 0 törlés
  1. 5 0
      panda/src/bullet/bulletContactCallbacks.h

+ 5 - 0
panda/src/bullet/bulletContactCallbacks.h

@@ -88,7 +88,12 @@ contact_added_callback(btManifoldPoint &cp,
       BulletManifoldPoint mp(cp);
       BulletContactCallbackData cbdata(mp, node0, node1, id0, id1, index0, index1);
 
+      // Release the world mutex object so that bullet methods can be called from the callback.
+      LightMutex &mutex = BulletWorld::get_global_lock();
+
+      mutex.release();
       bullet_contact_added_callback->do_callback(&cbdata);
+      mutex.acquire();
     }
   }