Fixing a memory leak introduced by the Character Physics type patch: a new btGhostPai...
authorMitchell Stokes <mogurijin@gmail.com>
Sun, 8 Jul 2012 20:05:40 +0000 (20:05 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Sun, 8 Jul 2012 20:05:40 +0000 (20:05 +0000)
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h

index 47cd4ff8da5ca3cfde86b2239b5207c3b6a9361c..3b49607ff1bf6d5e31a1b8ac747f0f19f3d56497 100644 (file)
@@ -338,6 +338,7 @@ m_enableSatCollisionDetection(false),
 m_solver(NULL),
 m_ownPairCache(NULL),
 m_filterCallback(NULL),
+m_ghostPairCallback(NULL),
 m_ownDispatcher(NULL),
 m_scalingPropagated(false)
 {
@@ -369,8 +370,9 @@ m_scalingPropagated(false)
        }
 
        m_filterCallback = new CcdOverlapFilterCallBack(this);
+       m_ghostPairCallback = new btGhostPairCallback();
        m_broadphase->getOverlappingPairCache()->setOverlapFilterCallback(m_filterCallback);
-       m_broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
+       m_broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(m_ghostPairCallback);
 
        setSolverType(1);//issues with quickstep and memory allocations
 //     m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
@@ -1886,6 +1888,9 @@ CcdPhysicsEnvironment::~CcdPhysicsEnvironment()
        if (NULL != m_filterCallback)
                delete m_filterCallback;
 
+       if (NULL != m_ghostPairCallback)
+               delete m_ghostPairCallback;
+
        if (NULL != m_collisionConfiguration)
                delete m_collisionConfiguration;
 
index ef1c08730057b6cdd117c82a8a1de3704b90b978..8d9c770b8c3cf8c5167d2a0afc4b415fdb26d9a6 100644 (file)
@@ -280,6 +280,8 @@ protected:
 
                class CcdOverlapFilterCallBack* m_filterCallback;
 
+               class btGhostPairCallback*      m_ghostPairCallback;
+
                class btDispatcher* m_ownDispatcher;
 
                bool    m_scalingPropagated;