BGE bug #18091: Hitbox of object X doesn't move along when object X is parented to...
authorBenoit Bolsee <benoit.bolsee@online.be>
Thu, 30 Apr 2009 19:00:17 +0000 (19:00 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Thu, 30 Apr 2009 19:00:17 +0000 (19:00 +0000)
source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
source/gameengine/Ketsji/KX_BulletPhysicsController.h

index 9e74706e1c021e4f90f78cab3cb213fba4e266e9..300a7906e811a7134925b6412bd8289c3d03253f 100644 (file)
@@ -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;
        }
 }
 
index 2174f0db4995a983cba44de7de8f0027764732a1..9d2afad1a5c2aa6560617c9a07296531281836de 100644 (file)
@@ -14,6 +14,7 @@ private:
        short int m_savedCollisionFilterMask;
        MT_Scalar m_savedMass;
        bool m_savedDyna;
+       bool m_suspended;
        btCollisionShape* m_bulletChildShape;
 
 public: