fixing some issues: force needs to wake up objects, property sensor issue, island...
[blender.git] / extern / bullet2 / src / BulletCollision / CollisionDispatch / btSimulationIslandManager.cpp
index 3f51e9ec0a61472f225c5bd777e0d03ebba23dda..5a642643eedc370ed05c51dfc1bd713c7b38edcd 100644 (file)
@@ -271,41 +271,50 @@ void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,
        int islandId;
 
 
-               //update the sleeping state for bodies, if all are sleeping
+       //solve the constraint for each islands, if there are contacts/constraints
        for (int startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
        {
                int islandId = getUnionFind().getElement(startIslandIndex).m_id;
 
-               for (endIslandIndex = startIslandIndex+1;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
+               bool islandSleeping = false;
+
+               for (endIslandIndex = startIslandIndex;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
                {
+                       int i = getUnionFind().getElement(endIslandIndex).m_sz;
+                       btCollisionObject* colObj0 = collisionObjects[i];
+                       if (!colObj0->isActive())
+                               islandSleeping = true;
                }
 
-               //find the accompanying contact manifold for this islandId
-               int numIslandManifolds = 0;
-               btPersistentManifold** startManifold = 0;
-
-               if (startManifoldIndex<numManifolds)
+               if (!islandSleeping)
                {
-                       int curIslandId = getIslandId(islandmanifold[startManifoldIndex]);
-                       if (curIslandId == islandId)
+                       //find the accompanying contact manifold for this islandId
+                       int numIslandManifolds = 0;
+                       btPersistentManifold** startManifold = 0;
+
+                       if (startManifoldIndex<numManifolds)
                        {
-                               startManifold = &islandmanifold[startManifoldIndex];
-                       
-                               for (endManifoldIndex = startManifoldIndex+1;(endManifoldIndex<numManifolds) && (islandId == getIslandId(islandmanifold[endManifoldIndex]));endManifoldIndex++)
+                               int curIslandId = getIslandId(islandmanifold[startManifoldIndex]);
+                               if (curIslandId == islandId)
                                {
+                                       startManifold = &islandmanifold[startManifoldIndex];
+                               
+                                       for (endManifoldIndex = startManifoldIndex+1;(endManifoldIndex<numManifolds) && (islandId == getIslandId(islandmanifold[endManifoldIndex]));endManifoldIndex++)
+                                       {
 
+                                       }
+                                       /// Process the actual simulation, only if not sleeping/deactivated
+                                       numIslandManifolds = endManifoldIndex-startManifoldIndex;
                                }
-                               /// Process the actual simulation, only if not sleeping/deactivated
-                               numIslandManifolds = endManifoldIndex-startManifoldIndex;
-                       }
 
-               }
+                       }
 
-               callback->ProcessIsland(startManifold,numIslandManifolds, islandId);
+                       callback->ProcessIsland(startManifold,numIslandManifolds, islandId);
 
-               if (numIslandManifolds)
-               {
-                       startManifoldIndex = endManifoldIndex;
+                       if (numIslandManifolds)
+                       {
+                               startManifoldIndex = endManifoldIndex;
+                       }
                }
        }
 }