32 int batchCost = bodies + 8 * manifolds + 4 * constraints;
140 int lastCapacity = 0;
141 bool isSorted =
true;
146 if (cap > lastCapacity)
196 int allocSize = numBodies;
220 if (freeIslands.
size() > 0)
223 int iFound = freeIslands.
size();
225 for (
int i = freeIslands.
size() - 1; i >= 0; --i)
227 if (freeIslands[i]->bodyArray.
capacity() >= allocSize)
230 island = freeIslands[i];
239 int iSrc = iDest + 1;
240 while (iSrc < freeIslands.
size())
242 freeIslands[iDest++] = freeIslands[iSrc++];
276 int endIslandIndex = 1;
277 int startIslandIndex;
280 for (startIslandIndex = 0; startIslandIndex < numElem; startIslandIndex = endIslandIndex)
283 for (endIslandIndex = startIslandIndex + 1; (endIslandIndex < numElem) && (
getUnionFind().
getElement(endIslandIndex).m_id == islandId); endIslandIndex++)
289 bool allSleeping =
true;
292 for (idx = startIslandIndex; idx < endIslandIndex; idx++)
317 for (idx = startIslandIndex; idx < endIslandIndex; idx++)
337 for (idx = startIslandIndex; idx < endIslandIndex; idx++)
365 int endIslandIndex = 1;
366 int startIslandIndex;
370 for (startIslandIndex = 0; startIslandIndex < numElem; startIslandIndex = endIslandIndex)
375 for (endIslandIndex = startIslandIndex; (endIslandIndex < numElem) && (
getUnionFind().
getElement(endIslandIndex).m_id == islandId); endIslandIndex++)
379 bool islandSleeping =
true;
380 for (
int iElem = startIslandIndex; iElem < endIslandIndex; iElem++)
386 islandSleeping =
false;
392 int numBodies = endIslandIndex - startIslandIndex;
397 for (
int iElem = startIslandIndex; iElem < endIslandIndex; iElem++)
411 for (
int i = 0; i < maxNumManifolds; i++)
441 island->manifoldArray.push_back(manifold);
451 for (
int i = 0; i < constraints.
size(); i++)
461 island->constraintArray.push_back(constraint);
486 while (destIslandIndex < lastIndex)
493 int firstIndex = lastIndex;
501 int batchCost =
calcBatchCost(numBodies, numManifolds, numConstraints);
506 if (firstIndex - 1 == destIslandIndex)
517 for (
int i = firstIndex; i <= lastIndex; ++i)
523 lastIndex = firstIndex - 1;
549 for (
int i = 0; i < islands.
size(); ++i)
561 : m_islandsPtr(islandsPtr), m_solverParams(solverParams)
568 for (
int i = iBegin; i < iEnd; ++i)
607 while (iBegin < islandsPtr->
size())
640 for (
int i = 0; i < maxNumManifolds; i++)
667 collisionObjects.
size(),
static void getElement(int arrayLen, const char *cur, const char *old, char *oldPtr, char *curData)
#define DISABLE_DEACTIVATION
#define WANTS_DEACTIVATION
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
#define SIMD_FORCE_INLINE
int btGetConstraintIslandId1(const btTypedConstraint *lhs)
bool btIsBodyInIsland(const btSimulationIslandManagerMt::Island &island, const btCollisionObject *obj)
int getIslandId(const btPersistentManifold *lhs)
int calcBatchCost(int bodies, int manifolds, int constraints)
void btParallelFor(int iBegin, int iEnd, int grainSize, const btIParallelForBody &body)
function object that routes calls to operator<
bool operator()(const btSimulationIslandManagerMt::Island *lhs, const btSimulationIslandManagerMt::Island *rhs) const
bool operator()(const btSimulationIslandManagerMt::Island *lhs, const btSimulationIslandManagerMt::Island *rhs) const
int size() const
return the number of elements in the array
void resize(int newsize, const T &fillData=T())
void quickSort(const L &CompareFunc)
void push_back(const T &_Val)
int capacity() const
return the pre-allocated (reserved) elements, this is at least as large as the total number of elemen...
btCollisionObject can be used to manage collision detection objects.
bool hasContactResponse() const
void activate(bool forceActivation=false) const
void setActivationState(int newState) const
bool isKinematicObject() const
void setDeactivationTime(btScalar time)
int getActivationState() const
CollisionWorld is interface and container for the collision detection.
btCollisionObjectArray & getCollisionObjectArray()
virtual btScalar solveGroup(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifold, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &info, class btIDebugDraw *debugDrawer, btDispatcher *dispatcher)=0
solve a group of constraints
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
virtual int getNumManifolds() const =0
virtual btPersistentManifold * getManifoldByIndexInternal(int index)=0
virtual bool needsResponse(const btCollisionObject *body0, const btCollisionObject *body1)=0
virtual btPersistentManifold ** getInternalManifoldPointer()=0
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
const btCollisionObject * getBody0() const
const btCollisionObject * getBody1() const
static int s_minimumContactManifoldsForBatching
btAlignedObjectArray< Island * > m_allocatedIslands
virtual void addBodiesToIslands(btCollisionWorld *collisionWorld)
virtual void buildAndProcessIslands(btDispatcher *dispatcher, btCollisionWorld *collisionWorld, btAlignedObjectArray< btTypedConstraint * > &constraints, const SolverParams &solverParams)
virtual void initIslandPools()
Island * getIsland(int id)
int m_batchIslandMinBodyCount
virtual Island * allocateIsland(int id, int numBodies)
btAlignedObjectArray< Island * > m_freeIslands
virtual ~btSimulationIslandManagerMt()
btAlignedObjectArray< Island * > m_lookupIslandFromId
virtual void addManifoldsToIslands(btDispatcher *dispatcher)
int m_minimumSolverBatchSize
virtual void addConstraintsToIslands(btAlignedObjectArray< btTypedConstraint * > &constraints)
IslandDispatchFunc m_islandDispatch
btAlignedObjectArray< Island * > m_activeIslands
static void parallelIslandDispatch(btAlignedObjectArray< Island * > *islandsPtr, const SolverParams &solverParams)
static void solveIsland(btConstraintSolver *solver, Island &island, const SolverParams &solverParams)
static void serialIslandDispatch(btAlignedObjectArray< Island * > *islandsPtr, const SolverParams &solverParams)
btSimulationIslandManagerMt()
virtual void mergeIslands()
virtual void buildIslands(btDispatcher *dispatcher, btCollisionWorld *colWorld)
btUnionFind & getUnionFind()
TypedConstraint is the baseclass for Bullet constraints and vehicles.
const btRigidBody & getRigidBodyA() const
const btRigidBody & getRigidBodyB() const
int getNumElements() const
btElement & getElement(int index)
void sortIslands()
this is a special operation, destroying the content of btUnionFind.
UpdateIslandDispatcher(btAlignedObjectArray< btSimulationIslandManagerMt::Island * > &islandsPtr, const btSimulationIslandManagerMt::SolverParams &solverParams)
void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
btAlignedObjectArray< btSimulationIslandManagerMt::Island * > & m_islandsPtr
const btSimulationIslandManagerMt::SolverParams & m_solverParams
btAlignedObjectArray< btTypedConstraint * > constraintArray
void append(const Island &other)
btAlignedObjectArray< btCollisionObject * > bodyArray
btAlignedObjectArray< btPersistentManifold * > manifoldArray
btContactSolverInfo * m_solverInfo
btDispatcher * m_dispatcher
btConstraintSolver * m_solverPool
btConstraintSolver * m_solverMt
btIDebugDraw * m_debugDrawer