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:
authorBenoit Bolsee <benoit.bolsee@online.be>2008-03-01 22:46:50 +0300
committerBenoit Bolsee <benoit.bolsee@online.be>2008-03-01 22:46:50 +0300
commit0db0f5734d358676b11eccc702cf02adb3174b7e (patch)
treedbed0e86663eeabe8d333892958310878bfbe533 /source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
parent44314581dc934dc99c9504edf671118a9f988b68 (diff)
Various mem leaks related to CValue reference count fixed
Diffstat (limited to 'source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index 5de2ab1b2dc..7b2c514db8a 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -858,6 +858,8 @@ static btCollisionShape* CreateBulletShapeFromMesh(RAS_MeshObject* meshobj, bool
//concaveShape = new btTriangleMeshShape( collisionMeshData );
concaveShape->recalcLocalAabb();
+ if (collisionMeshShape)
+ delete collisionMeshShape;
collisionMeshShape = concaveShape;
}
@@ -866,8 +868,10 @@ static btCollisionShape* CreateBulletShapeFromMesh(RAS_MeshObject* meshobj, bool
return collisionMeshShape;
}
-
- delete collisionMeshShape;
+ if (collisionMeshShape)
+ delete collisionMeshShape;
+ if (collisionMeshData)
+ delete collisionMeshData;
return NULL;
}
@@ -1021,7 +1025,10 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
// ci.m_localInertiaTensor.setValue(0.1f,0.1f,0.1f);
if (!bm)
+ {
+ delete motionstate;
return;
+ }
bm->setMargin(0.06);
@@ -1057,6 +1064,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
compoundShape->addChildShape(childTrans,bm);
+ kxscene->AddShape(bm);
//do some recalc?
//recalc inertia for rigidbody
if (!rigidbody->isStaticOrKinematicObject())
@@ -1076,6 +1084,9 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
btTransform identTrans;
identTrans.setIdentity();
compoundShape->addChildShape(identTrans,bm);
+ //note abount compoundShape: Bullet does not delete the child shapes when
+ //the compound shape is deleted, so insert also the child shapes
+ kxscene->AddShape(bm);
bm = compoundShape;
}
@@ -1112,9 +1123,6 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
ci.m_collisionShape = bm;
-
-
-
ci.m_friction = smmaterial->m_friction;//tweak the friction a bit, so the default 0.5 works nice
ci.m_restitution = smmaterial->m_restitution;
ci.m_physicsEnv = env;
@@ -1127,6 +1135,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter);
KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna);
+ //remember that we created a shape so that we can delete it when the scene is removed (bullet will not delete it)
+ kxscene->AddShape(bm);
if (objprop->m_in_active_layer)
{