diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-03-10 00:51:38 +0300 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-03-10 00:51:38 +0300 |
commit | 52293831b26f34547acf100603c87296deba7a60 (patch) | |
tree | 1eb228a4a0c8f09170b6cf02a8fbbe4573426a97 /source/gameengine/Ketsji/KX_BulletPhysicsController.cpp | |
parent | 822e51bd2d663f82d360d474192718660cc9a35c (diff) |
BGE fix: game object to controller links consistancy maintained regardless of order of deletion
AddObject actuator forces last created object to hang in memory even after object is removed from scene => bad link between object and physic controller that causes Blender to crash in case a python script tries to use it (bad programming anyway).
This patch avoids the crash by maintaining consistent links at all time.
Diffstat (limited to 'source/gameengine/Ketsji/KX_BulletPhysicsController.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_BulletPhysicsController.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index aa5d1f1cec1..aa7c75e9633 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -24,7 +24,18 @@ CcdPhysicsController(ci) KX_BulletPhysicsController::~KX_BulletPhysicsController () { - + // The game object has a direct link to + if (m_pObject) + { + // If we cheat in SetObject, we must also cheat here otherwise the + // object will still things it has a physical controller + // Note that it requires that m_pObject is reset in case the object is deleted + // before the controller (usual case, see KX_Scene::RemoveNodeDestructObjec) + // The non usual case is when the object is not deleted because its reference is hanging + // in a AddObject actuator but the node is deleted. This case is covered here. + KX_GameObject* gameobj = (KX_GameObject*) m_pObject->GetSGClientObject(); + gameobj->SetPhysicsController(NULL,false); + } } void KX_BulletPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) @@ -58,6 +69,7 @@ void KX_BulletPhysicsController::SetObject (SG_IObject* object) } + void KX_BulletPhysicsController::setMargin (float collisionMargin) { CcdPhysicsController::SetMargin(collisionMargin); |