Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.h5
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp26
2 files changed, 26 insertions, 5 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
index 4fcdc70c5a8..e3172e7fc45 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
@@ -515,6 +515,11 @@ protected:
return (--m_registerCount == 0) ? true : false;
}
+ bool Registered() const
+ {
+ return (m_registerCount != 0);
+ }
+
void addCcdConstraintRef(btTypedConstraint* c);
void removeCcdConstraintRef(btTypedConstraint* c);
btTypedConstraint* getCcdConstraintRef(int index);
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index c81d9c7de94..37cc26f6364 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -466,6 +466,14 @@ void CcdPhysicsEnvironment::AddCcdPhysicsController(CcdPhysicsController* ctrl)
return;
}
+ /* In the case of compound child controller (see also RemoveCcdPhysicsController)
+ * we add the controller to the trigger controlers list : m_triggerControllers
+ * if it use collision callbacks.
+ */
+ if (ctrl->Registered()) {
+ m_triggerControllers.insert(ctrl);
+ }
+
btRigidBody* body = ctrl->GetRigidBody();
btCollisionObject* obj = ctrl->GetCollisionObject();
@@ -508,15 +516,21 @@ void CcdPhysicsEnvironment::AddCcdPhysicsController(CcdPhysicsController* ctrl)
bool CcdPhysicsEnvironment::RemoveCcdPhysicsController(CcdPhysicsController* ctrl)
{
- // the controller is still used as sensor
- if (ctrl->m_registerCount != 0)
- printf("Warning: removing controller with non-zero m_registerCount: %d\n", ctrl->m_registerCount);
-
// if the physics controller is already removed we do nothing
- if (!m_controllers.erase(ctrl) || !m_triggerControllers.erase(ctrl)) {
+ if (!m_controllers.erase(ctrl)) {
return false;
}
+ /* In the case of compound child controller which use collision callbacks
+ * we remove it from the m_triggerControllers list but leave m_registerCount
+ * to know in AddCcdPhysicsController if we have to add it in m_triggerControllers
+ * and to avoid an useless added in RequestCollisionCallback, indeed we can't register
+ * more than one time a controller.
+ */
+ if (ctrl->Registered()) {
+ m_triggerControllers.erase(ctrl);
+ }
+
//also remove constraint
btRigidBody* body = ctrl->GetRigidBody();
if (body)
@@ -567,6 +581,8 @@ bool CcdPhysicsEnvironment::RemoveCcdPhysicsController(CcdPhysicsController* ctr
}
}
}
+
+ return true;
}
void CcdPhysicsEnvironment::UpdateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask)