Blender  V3.3
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 
64 protected:
66  btAlignedObjectArray<Island*> m_activeIslands; // islands actively in use
67  btAlignedObjectArray<Island*> m_freeIslands; // islands ready to be reused
68  btAlignedObjectArray<Island*> m_lookupIslandFromId; // big lookup table to map islandId to Island pointer
73 
74  Island* getIsland(int id);
75  virtual Island* allocateIsland(int id, int numBodies);
76  virtual void initIslandPools();
77  virtual void addBodiesToIslands(btCollisionWorld* collisionWorld);
78  virtual void addManifoldsToIslands(btDispatcher* dispatcher);
80  virtual void mergeIslands();
81 
82 public:
85 
86  virtual void buildAndProcessIslands(btDispatcher* dispatcher,
87  btCollisionWorld* collisionWorld,
89  const SolverParams& solverParams);
90 
91  virtual void buildIslands(btDispatcher* dispatcher, btCollisionWorld* colWorld);
92 
94  {
96  }
98  {
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 #endif //BT_SIMULATION_ISLAND_MANAGER_H
btSequentialImpulseConstraintSolverMt int btPersistentManifold int btTypedConstraint ** constraints
btSequentialImpulseConstraintSolverMt int numBodies
btTypedConstraint(btTypedConstraintType type, btRigidBody &rbA)
CollisionWorld is interface and container for the collision detection.
btAlignedObjectArray< Island * > m_allocatedIslands
virtual void addBodiesToIslands(btCollisionWorld *collisionWorld)
virtual void buildAndProcessIslands(btDispatcher *dispatcher, btCollisionWorld *collisionWorld, btAlignedObjectArray< btTypedConstraint * > &constraints, const SolverParams &solverParams)
IslandDispatchFunc getIslandDispatchFunction() const
virtual Island * allocateIsland(int id, int numBodies)
btAlignedObjectArray< Island * > m_freeIslands
btAlignedObjectArray< Island * > m_lookupIslandFromId
virtual void addManifoldsToIslands(btDispatcher *dispatcher)
virtual void addConstraintsToIslands(btAlignedObjectArray< btTypedConstraint * > &constraints)
void(* IslandDispatchFunc)(btAlignedObjectArray< Island * > *islands, const SolverParams &solverParams)
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)
virtual void buildIslands(btDispatcher *dispatcher, btCollisionWorld *colWorld)
void setIslandDispatchFunction(IslandDispatchFunc func)
SimulationIslandManager creates and handles simulation islands, using btUnionFind.
SyclQueue void void size_t num_bytes void
btAlignedObjectArray< btTypedConstraint * > constraintArray
btAlignedObjectArray< btCollisionObject * > bodyArray
btAlignedObjectArray< btPersistentManifold * > manifoldArray