diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-07-18 18:40:24 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-07-18 18:40:24 +0400 |
commit | a397b4b82fb9c658bb9e034e96692b9e5af5819a (patch) | |
tree | 75e8fd2dca8f95ebcd97c1af11f96f88086e0d10 /source/gameengine/Ketsji/KX_BulletPhysicsController.cpp | |
parent | 6786c517af25234de320fc459252390e4454d85f (diff) |
BGE bug fix (good for 2.47): SetParent actuator did not work on dynamic objects. Dynamics will now be disabled automatically and the object will be set ghost for the duration of the parenting; this is to avoid static interaction with the parent object. The dynamic state is restored when the parenting is removed with RemoveParent actuator. This fix also applies to setParent() and removeParent() python functions.
Diffstat (limited to 'source/gameengine/Ketsji/KX_BulletPhysicsController.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_BulletPhysicsController.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index 70443ced7a9..dba11efef72 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -17,7 +17,8 @@ KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna) : KX_IPhysicsController(dyna,(PHY_IPhysicsController*)this), -CcdPhysicsController(ci) +CcdPhysicsController(ci), +m_savedCollisionFlags(0) { } @@ -161,14 +162,26 @@ void KX_BulletPhysicsController::setRigidBody(bool rigid) { } -void KX_BulletPhysicsController::SuspendDynamics() +void KX_BulletPhysicsController::SuspendDynamics(bool ghost) { - GetRigidBody()->setActivationState(DISABLE_SIMULATION); - + btRigidBody *body = GetRigidBody(); + if (body->getActivationState() != DISABLE_SIMULATION) + { + m_savedCollisionFlags = body->getCollisionFlags(); + body->setActivationState(DISABLE_SIMULATION); + body->setCollisionFlags((btCollisionObject::CF_STATIC_OBJECT)| + ((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:0)); + } } + void KX_BulletPhysicsController::RestoreDynamics() { - GetRigidBody()->forceActivationState(ACTIVE_TAG); + btRigidBody *body = GetRigidBody(); + if (body->getActivationState() == DISABLE_SIMULATION) + { + GetRigidBody()->forceActivationState(ACTIVE_TAG); + body->setCollisionFlags(m_savedCollisionFlags); + } } SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode) |