[Bf-blender-cvs] [a790e17] master: BGE: Fix T38448: Bullet constraint memory leak.
Porteries Tristan
noreply at git.blender.org
Tue Aug 11 13:36:31 CEST 2015
Commit: a790e172d0281e64517ff44d80f1c0139c3ab665
Author: Porteries Tristan
Date: Tue Aug 11 12:56:57 2015 +0200
Branches: master
https://developer.blender.org/rBa790e172d0281e64517ff44d80f1c0139c3ab665
BGE: Fix T38448: Bullet constraint memory leak.
===================================================================
M source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
===================================================================
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 53c007f..273e732 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -537,8 +537,18 @@ bool CcdPhysicsEnvironment::RemoveCcdPhysicsController(CcdPhysicsController* ctr
con->getRigidBodyA().activate();
con->getRigidBodyB().activate();
m_dynamicsWorld->removeConstraint(con);
+
+ // The other physics controller in the constraint, can't be NULL.
+ CcdPhysicsController *otherCtrl = (body == &con->getRigidBodyA()) ?
+ (CcdPhysicsController *)con->getRigidBodyB().getUserPointer() :
+ (CcdPhysicsController *)con->getRigidBodyA().getUserPointer();
+
+ otherCtrl->removeCcdConstraintRef(con);
ctrl->removeCcdConstraintRef(con);
- //delete con; //might be kept by python KX_ConstraintWrapper
+ /** Since we remove the constraint in the onwer and the target, we can delete it,
+ * KX_ConstraintWrapper keep the constraint id not the pointer, so no problems.
+ */
+ delete con;
}
m_dynamicsWorld->removeRigidBody(ctrl->GetRigidBody());
More information about the Bf-blender-cvs
mailing list