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
path: root/source
diff options
context:
space:
mode:
authorPorteries Tristan <republicthunderbolt9@gmail.com>2015-06-19 12:52:37 +0300
committerPorteries Tristan <republicthunderbolt9@gmail.com>2015-06-19 17:40:42 +0300
commite9406256d09c5b027c59020cc339da5ae6304f43 (patch)
tree4b1146944b3a390b59f1b4d6e5fa6ebf29b9de99 /source
parentae0ed5e9d57f1e74cdc689307c090f0875c07e45 (diff)
BGE: Simplify collision callback registration.
Remove list m_triggerController and just use getter CcdPhysicsController->Registered(). Reviewers: sybren, agoose77
Diffstat (limited to 'source')
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp42
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h1
2 files changed, 9 insertions, 34 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 96505fa6e01..89c8c124bc8 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -466,14 +466,6 @@ 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();
@@ -521,16 +513,6 @@ bool CcdPhysicsEnvironment::RemoveCcdPhysicsController(CcdPhysicsController* ctr
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)
@@ -2199,10 +2181,7 @@ void CcdPhysicsEnvironment::AddSensor(PHY_IPhysicsController* ctrl)
bool CcdPhysicsEnvironment::RemoveCollisionCallback(PHY_IPhysicsController* ctrl)
{
CcdPhysicsController* ccdCtrl = (CcdPhysicsController*)ctrl;
- if (!ccdCtrl->Unregister())
- return false;
- m_triggerControllers.erase(ccdCtrl);
- return true;
+ return ccdCtrl->Unregister();
}
@@ -2246,11 +2225,7 @@ void CcdPhysicsEnvironment::AddTouchCallback(int response_class, PHY_ResponseCal
bool CcdPhysicsEnvironment::RequestCollisionCallback(PHY_IPhysicsController* ctrl)
{
CcdPhysicsController* ccdCtrl = static_cast<CcdPhysicsController*>(ctrl);
-
- if (!ccdCtrl->Register())
- return false;
- m_triggerControllers.insert(ccdCtrl);
- return true;
+ return !ccdCtrl->Register();
}
void CcdPhysicsEnvironment::CallbackTriggers()
@@ -2289,16 +2264,17 @@ void CcdPhysicsEnvironment::CallbackTriggers()
//m_internalOwner is set in 'addPhysicsController'
CcdPhysicsController* ctrl0 = static_cast<CcdPhysicsController*>(rb0->getUserPointer());
CcdPhysicsController* ctrl1 = static_cast<CcdPhysicsController*>(rb1->getUserPointer());
+ bool usecallback = false;
- std::set<CcdPhysicsController*>::const_iterator iter = m_triggerControllers.find(ctrl0);
- if (iter == m_triggerControllers.end())
- {
- iter = m_triggerControllers.find(ctrl1);
+ // Test if one of the controller is registered and use collision callback.
+ if (ctrl0->Registered())
+ usecallback = true;
+ else if (ctrl1->Registered()) {
colliding_ctrl0 = false;
+ usecallback = true;
}
- if (iter != m_triggerControllers.end())
- {
+ if (usecallback) {
static PHY_CollData coll_data;
const btManifoldPoint &cp = manifold->getContactPoint(0);
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
index 94aea215478..e1988478b71 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
@@ -291,7 +291,6 @@ protected:
std::set<CcdPhysicsController*> m_controllers;
- std::set<CcdPhysicsController*> m_triggerControllers;
PHY_ResponseCallback m_triggerCallbacks[PHY_NUM_RESPONSE];
void* m_triggerCallbacksUserPtrs[PHY_NUM_RESPONSE];