From c9cd3364005f29368c5412560adb86fea0fc381d Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 27 Oct 2015 15:01:48 -0700 Subject: [PATCH] fix for bad contacts after changing avatar models --- libraries/physics/src/PhysicsEngine.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index a6b8dbe959..d6772f8d36 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -246,6 +246,11 @@ void PhysicsEngine::stepSimulation() { // be done on the main thread during the pre-simulation stuff if (_myAvatarController->needsRemoval()) { _myAvatarController->setDynamicsWorld(nullptr); + + // We must remove any existing contacts for the avatar so that any new contacts will have + // valid data. MyAvatar's RigidBody is the ONLY one in the simulation that does not yet + // have a MotionState so we pass nullptr to removeContacts(). + removeContacts(nullptr); } _myAvatarController->updateShapeIfNecessary(); if (_myAvatarController->needsAddition()) {