fixing some issues: force needs to wake up objects, property sensor issue, island...
[blender.git] / extern / bullet2 / src / BulletCollision / CollisionDispatch / btSimulationIslandManager.cpp
index 332870080043a9c05265f66b49e031d67832f3ed..5a642643eedc370ed05c51dfc1bd713c7b38edcd 100644 (file)
@@ -268,17 +268,53 @@ void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,
        int startManifoldIndex = 0;
        int endManifoldIndex = 1;
 
-       for (startManifoldIndex=0;startManifoldIndex<numManifolds;startManifoldIndex = endManifoldIndex)
+       int islandId;
+
+
+       //solve the constraint for each islands, if there are contacts/constraints
+       for (int startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
        {
-               int islandId = getIslandId(islandmanifold[startManifoldIndex]);
-               for (endManifoldIndex = startManifoldIndex+1;(endManifoldIndex<numManifolds) && (islandId == getIslandId(islandmanifold[endManifoldIndex]));endManifoldIndex++)
+               int islandId = getUnionFind().getElement(startIslandIndex).m_id;
+
+               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;
                }
-               /// Process the actual simulation, only if not sleeping/deactivated
-               int numIslandManifolds = endManifoldIndex-startManifoldIndex;
-               if (numIslandManifolds)
+
+               if (!islandSleeping)
                {
-                       callback->ProcessIsland(&islandmanifold[startManifoldIndex],numIslandManifolds);
+                       //find the accompanying contact manifold for this islandId
+                       int numIslandManifolds = 0;
+                       btPersistentManifold** startManifold = 0;
+
+                       if (startManifoldIndex<numManifolds)
+                       {
+                               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;
+                               }
+
+                       }
+
+                       callback->ProcessIsland(startManifold,numIslandManifolds, islandId);
+
+                       if (numIslandManifolds)
+                       {
+                               startManifoldIndex = endManifoldIndex;
+                       }
                }
        }
 }