diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2009-04-30 23:00:17 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2009-04-30 23:00:17 +0400 |
commit | 2ec50d7bb282c3962d752771ceed8cb152f956a9 (patch) | |
tree | b64b395ef54250dfaccfefb5b8460d6324768cf2 /source/gameengine/Ketsji | |
parent | 8570071e4075b51262ad2adae4881ca3077916bb (diff) |
BGE bug #18091: Hitbox of object X doesn't move along when object X is parented to object Y.
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r-- | source/gameengine/Ketsji/KX_BulletPhysicsController.cpp | 19 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_BulletPhysicsController.h | 1 |
2 files changed, 12 insertions, 8 deletions
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index 9e74706e1c0..300a7906e81 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -21,9 +21,13 @@ KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInf : KX_IPhysicsController(dyna,compound,(PHY_IPhysicsController*)this), CcdPhysicsController(ci), m_savedCollisionFlags(0), +m_savedCollisionFilterGroup(0), +m_savedCollisionFilterMask(0), +m_savedMass(0.0), +m_savedDyna(false), +m_suspended(false), m_bulletChildShape(NULL) { - } KX_BulletPhysicsController::~KX_BulletPhysicsController () @@ -337,8 +341,7 @@ void KX_BulletPhysicsController::RemoveCompoundChild(KX_IPhysicsController* c void KX_BulletPhysicsController::SetMass(MT_Scalar newmass) { btRigidBody *body = GetRigidBody(); - if (body && body->getActivationState() != DISABLE_SIMULATION && - newmass>MT_EPSILON && GetMass()>MT_EPSILON) + if (body && !m_suspended && newmass>MT_EPSILON && GetMass()>MT_EPSILON) { btVector3 grav = body->getGravity(); btVector3 accel = grav / GetMass(); @@ -356,7 +359,7 @@ void KX_BulletPhysicsController::SetMass(MT_Scalar newmass) void KX_BulletPhysicsController::SuspendDynamics(bool ghost) { btRigidBody *body = GetRigidBody(); - if (body && body->getActivationState() != DISABLE_SIMULATION) + if (body && !m_suspended) { btBroadphaseProxy* handle = body->getBroadphaseHandle(); m_savedCollisionFlags = body->getCollisionFlags(); @@ -364,8 +367,7 @@ void KX_BulletPhysicsController::SuspendDynamics(bool ghost) m_savedDyna = m_bDyna; m_savedCollisionFilterGroup = handle->m_collisionFilterGroup; m_savedCollisionFilterMask = handle->m_collisionFilterMask; - m_savedActivationState = body->getActivationState(); - body->forceActivationState(DISABLE_SIMULATION); + m_suspended = true; GetPhysicsEnvironment()->updateCcdPhysicsController(this, 0.0, btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)), @@ -378,15 +380,16 @@ void KX_BulletPhysicsController::SuspendDynamics(bool ghost) void KX_BulletPhysicsController::RestoreDynamics() { btRigidBody *body = GetRigidBody(); - if (body && body->getActivationState() == DISABLE_SIMULATION) + if (body && m_suspended) { GetPhysicsEnvironment()->updateCcdPhysicsController(this, m_savedMass, m_savedCollisionFlags, m_savedCollisionFilterGroup, m_savedCollisionFilterMask); - body->forceActivationState(m_savedActivationState); + body->activate(); m_bDyna = m_savedDyna; + m_suspended = false; } } diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h index 2174f0db499..9d2afad1a5c 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h @@ -14,6 +14,7 @@ private: short int m_savedCollisionFilterMask; MT_Scalar m_savedMass; bool m_savedDyna; + bool m_suspended; btCollisionShape* m_bulletChildShape; public: |