some fixes, related to object activation in game blender
authorErwin Coumans <blender@erwincoumans.com>
Tue, 21 Nov 2006 11:56:02 +0000 (11:56 +0000)
committerErwin Coumans <blender@erwincoumans.com>
Tue, 21 Nov 2006 11:56:02 +0000 (11:56 +0000)
extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp
extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp

index 9cd2828dcad8a40a5f15c65a3317ebb7922caa2a..13fa0b5baa93c14cf2d6a82ceef27f0feccea2c1 100644 (file)
@@ -41,9 +41,9 @@ void btCollisionObject::forceActivationState(int newState)
        m_activationState1 = newState;
 }
 
-void btCollisionObject::activate()
+void btCollisionObject::activate(bool forceActivation)
 {
-       if (!(m_collisionFlags & (CF_STATIC_OBJECT|CF_KINEMATIC_OBJECT)))
+       if (forceActivation || !(m_collisionFlags & (CF_STATIC_OBJECT|CF_KINEMATIC_OBJECT)))
        {
                setActivationState(ACTIVE_TAG);
                m_deactivationTime = 0.f;
index b85534c1d15c5dedb28a2d4231c5965227537da1..9a0129ac29cf3b4c76e603c13ebff939fccf779e 100644 (file)
@@ -148,7 +148,7 @@ public:
 
        void forceActivationState(int newState);
 
-       void    activate();
+       void    activate(bool forceActivation = false);
 
        inline bool isActive() const
        {
index be4f8686f30e505b332d485df9731e7729327fb2..332870080043a9c05265f66b49e031d67832f3ed 100644 (file)
@@ -176,7 +176,8 @@ void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,
                                }
                        }
                }
-               
+                       
+
                if (allSleeping)
                {
                        int idx;
@@ -239,14 +240,15 @@ void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,
                 if (((colObj0) && colObj0->getActivationState() != ISLAND_SLEEPING) ||
                        ((colObj1) && colObj1->getActivationState() != ISLAND_SLEEPING))
                {
+               
                        //kinematic objects don't merge islands, but wake up all connected objects
-                       if (colObj0->isKinematicObject() && colObj0->getActivationState() != ISLAND_SLEEPING)
+                       if (colObj0->isStaticOrKinematicObject() && colObj0->getActivationState() != ISLAND_SLEEPING)
                        {
-                               colObj1->setActivationState(ACTIVE_TAG);
+                               colObj1->activate();
                        }
-                       if (colObj1->isKinematicObject() && colObj1->getActivationState() != ISLAND_SLEEPING)
+                       if (colObj1->isStaticOrKinematicObject() && colObj1->getActivationState() != ISLAND_SLEEPING)
                        {
-                               colObj0->setActivationState(ACTIVE_TAG);
+                               colObj0->activate();
                        }
 
                        //filtering for response
index bdde013aadbffbd16c8742e65e69c6dbbfdf62b8..0dece6b20e6f240f83799cc27c6eb365dcc7e9ef 100644 (file)
@@ -368,8 +368,14 @@ void       btDiscreteDynamicsWorld::updateActivationState(float timeStep)
 
                        if (body->wantsSleeping())
                        {
-                               if (body->getActivationState() == ACTIVE_TAG)
-                                       body->setActivationState( WANTS_DEACTIVATION );
+                               if (body->isStaticOrKinematicObject())
+                               {
+                                       body->setActivationState(ISLAND_SLEEPING);
+                               } else
+                               {
+                                       if (body->getActivationState() == ACTIVE_TAG)
+                                               body->setActivationState( WANTS_DEACTIVATION );
+                               }
                        } else
                        {
                                if (body->getActivationState() != DISABLE_DEACTIVATION)