Logo Search packages:      
Sourcecode: blender version File versions  Download package

void btSimulationIslandManager::buildAndProcessIslands ( btDispatcher dispatcher,
btCollisionWorld collisionWorld,
IslandCallback *  callback 
)

Todo:
: this is random access, it can be walked 'cache friendly'!

Process the actual simulation, only if not sleeping/deactivated

Definition at line 296 of file btSimulationIslandManager.cpp.

References buildIslands(), btCollisionWorld::getCollisionObjectArray(), btUnionFind::getElement(), btDispatcher::getInternalManifoldPointer(), btUnionFind::getNumElements(), btDispatcher::getNumManifolds(), btAlignedObjectArray< T >::push_back(), btAlignedObjectArray< T >::quickSort(), btAlignedObjectArray< T >::resize(), and btAlignedObjectArray< T >::size().

Referenced by btDiscreteDynamicsWorld::solveConstraints().

{
      btCollisionObjectArray& collisionObjects = collisionWorld->getCollisionObjectArray();

      buildIslands(dispatcher,collisionWorld);

      int endIslandIndex=1;
      int startIslandIndex;
      int numElem = getUnionFind().getNumElements();

      BT_PROFILE("processIslands");

      if(!m_splitIslands)
      {
            btPersistentManifold** manifold = dispatcher->getInternalManifoldPointer();
            int maxNumManifolds = dispatcher->getNumManifolds();
            callback->ProcessIsland(&collisionObjects[0],collisionObjects.size(),manifold,maxNumManifolds, -1);
      }
      else
      {
            // Sort manifolds, based on islands
            // Sort the vector using predicate and std::sort
            //std::sort(islandmanifold.begin(), islandmanifold.end(), btPersistentManifoldSortPredicate);

            int numManifolds = int (m_islandmanifold.size());

            //we should do radix sort, it it much faster (O(n) instead of O (n log2(n))
            m_islandmanifold.quickSort(btPersistentManifoldSortPredicate());

            //now process all active islands (sets of manifolds for now)

            int startManifoldIndex = 0;
            int endManifoldIndex = 1;

            //int islandId;

            

      //    printf("Start Islands\n");

            //traverse the simulation islands, and call the solver, unless all objects are sleeping/deactivated
            for ( startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
            {
                  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];
                                          m_islandBodies.push_back(colObj0);
                                          if (!colObj0->isActive())
                                                      islandSleeping = true;
                              }
                      

                  //find the accompanying contact manifold for this islandId
                  int numIslandManifolds = 0;
                  btPersistentManifold** startManifold = 0;

                  if (startManifoldIndex<numManifolds)
                  {
                        int curIslandId = getIslandId(m_islandmanifold[startManifoldIndex]);
                        if (curIslandId == islandId)
                        {
                              startManifold = &m_islandmanifold[startManifoldIndex];
                        
                              for (endManifoldIndex = startManifoldIndex+1;(endManifoldIndex<numManifolds) && (islandId == getIslandId(m_islandmanifold[endManifoldIndex]));endManifoldIndex++)
                              {

                              }
                              /// Process the actual simulation, only if not sleeping/deactivated
                              numIslandManifolds = endManifoldIndex-startManifoldIndex;
                        }

                  }

                  if (!islandSleeping)
                  {
                        callback->ProcessIsland(&m_islandBodies[0],m_islandBodies.size(),startManifold,numIslandManifolds, islandId);
      //                printf("Island callback of size:%d bodies, %d manifolds\n",islandBodies.size(),numIslandManifolds);
                  }
                  
                  if (numIslandManifolds)
                  {
                        startManifoldIndex = endManifoldIndex;
                  }

                  m_islandBodies.resize(0);
            }
      } // else if(!splitIslands) 

}


Generated by  Doxygen 1.6.0   Back to index