Bullet Collision Detection & Physics Library
btSimulationIslandManagerMt.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 
16 #ifndef BT_SIMULATION_ISLAND_MANAGER_MT_H
17 #define BT_SIMULATION_ISLAND_MANAGER_MT_H
18 
20 
21 class btTypedConstraint;
22 class btConstraintSolver;
23 struct btContactSolverInfo;
24 class btIDebugDraw;
25 
36 {
37 public:
38  struct Island
39  {
40  // a simulation island consisting of bodies, manifolds and constraints,
41  // to be passed into a constraint solver.
45  int id; // island id
46  bool isSleeping;
47 
48  void append( const Island& other ); // add bodies, manifolds, constraints to my own
49  };
50  struct SolverParams
51  {
57  };
58  static void solveIsland(btConstraintSolver* solver, Island& island, const SolverParams& solverParams);
59 
60  typedef void( *IslandDispatchFunc ) ( btAlignedObjectArray<Island*>* islands, const SolverParams& solverParams );
61  static void serialIslandDispatch( btAlignedObjectArray<Island*>* islandsPtr, const SolverParams& solverParams );
62  static void parallelIslandDispatch( btAlignedObjectArray<Island*>* islandsPtr, const SolverParams& solverParams );
63 protected:
65  btAlignedObjectArray<Island*> m_activeIslands; // islands actively in use
66  btAlignedObjectArray<Island*> m_freeIslands; // islands ready to be reused
67  btAlignedObjectArray<Island*> m_lookupIslandFromId; // big lookup table to map islandId to Island pointer
72 
73  Island* getIsland( int id );
74  virtual Island* allocateIsland( int id, int numBodies );
75  virtual void initIslandPools();
76  virtual void addBodiesToIslands( btCollisionWorld* collisionWorld );
77  virtual void addManifoldsToIslands( btDispatcher* dispatcher );
79  virtual void mergeIslands();
80 
81 public:
84 
85  virtual void buildAndProcessIslands( btDispatcher* dispatcher,
86  btCollisionWorld* collisionWorld,
88  const SolverParams& solverParams
89  );
90 
91  virtual void buildIslands(btDispatcher* dispatcher,btCollisionWorld* colWorld);
92 
94  {
96  }
98  {
99  m_minimumSolverBatchSize = sz;
100  }
102  {
103  return m_islandDispatch;
104  }
105  // allow users to set their own dispatch function for multithreaded dispatch
107  {
108  m_islandDispatch = func;
109  }
110 };
111 
112 
113 #endif //BT_SIMULATION_ISLAND_MANAGER_H
114 
virtual Island * allocateIsland(int id, int numBodies)
void setIslandDispatchFunction(IslandDispatchFunc func)
static void serialIslandDispatch(btAlignedObjectArray< Island * > *islandsPtr, const SolverParams &solverParams)
btAlignedObjectArray< btPersistentManifold * > manifoldArray
btAlignedObjectArray< Island * > m_freeIslands
static void parallelIslandDispatch(btAlignedObjectArray< Island * > *islandsPtr, const SolverParams &solverParams)
btAlignedObjectArray< Island * > m_lookupIslandFromId
IslandDispatchFunc getIslandDispatchFunction() const
SimulationIslandManager creates and handles simulation islands, using btUnionFind.
virtual void addBodiesToIslands(btCollisionWorld *collisionWorld)
void(* IslandDispatchFunc)(btAlignedObjectArray< Island * > *islands, const SolverParams &solverParams)
btAlignedObjectArray< Island * > m_activeIslands
btAlignedObjectArray< Island * > m_allocatedIslands
virtual void buildAndProcessIslands(btDispatcher *dispatcher, btCollisionWorld *collisionWorld, btAlignedObjectArray< btTypedConstraint * > &constraints, const SolverParams &solverParams)
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
Definition: btIDebugDraw.h:29
btAlignedObjectArray< btTypedConstraint * > constraintArray
virtual void addConstraintsToIslands(btAlignedObjectArray< btTypedConstraint * > &constraints)
static void solveIsland(btConstraintSolver *solver, Island &island, const SolverParams &solverParams)
CollisionWorld is interface and container for the collision detection.
TypedConstraint is the baseclass for Bullet constraints and vehicles.
virtual void buildIslands(btDispatcher *dispatcher, btCollisionWorld *colWorld)
btAlignedObjectArray< btCollisionObject * > bodyArray
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:77
virtual void addManifoldsToIslands(btDispatcher *dispatcher)
SimulationIslandManagerMt – Multithread capable version of SimulationIslandManager Splits the world ...