Bullet Collision Detection & Physics Library: btSimulationIslandManagerMt.h Source File

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
19 #include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
20
21 class btTypedConstraint;
22 class btConstraintSolver;
23 struct btContactSolverInfo;
24 class btIDebugDraw;
25
35 class btSimulationIslandManagerMt : public btSimulationIslandManager
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.
42 btAlignedObjectArray<btCollisionObject*> bodyArray;
43 btAlignedObjectArray<btPersistentManifold*> manifoldArray;
44 btAlignedObjectArray<btTypedConstraint*> constraintArray;
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 {
52 btConstraintSolver* m_solverPool;
53 btConstraintSolver* m_solverMt;
54 btContactSolverInfo* m_solverInfo;
55 btIDebugDraw* m_debugDrawer;
56 btDispatcher* m_dispatcher;
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:
65 btAlignedObjectArray<Island*> m_allocatedIslands; // owner of all Islands
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
69 Island* m_batchIsland;
70 int m_minimumSolverBatchSize;
71 int m_batchIslandMinBodyCount;
72 IslandDispatchFunc m_islandDispatch;
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);
79 virtual void addConstraintsToIslands(btAlignedObjectArray<btTypedConstraint*>& constraints);
80 virtual void mergeIslands();
81
82 public:
83 btSimulationIslandManagerMt();
84 virtual ~btSimulationIslandManagerMt();
85
86 virtual void buildAndProcessIslands(btDispatcher* dispatcher,
87 btCollisionWorld* collisionWorld,
88 btAlignedObjectArray<btTypedConstraint*>& constraints,
89 const SolverParams& solverParams);
90
91 virtual void buildIslands(btDispatcher* dispatcher, btCollisionWorld* colWorld);
92
93 int getMinimumSolverBatchSize() const
94 {
95 return m_minimumSolverBatchSize;
96 }
97 void setMinimumSolverBatchSize(int sz)
98 {
99 m_minimumSolverBatchSize = sz;
100 }
101 IslandDispatchFunc getIslandDispatchFunction() const
102 {
103 return m_islandDispatch;
104 }
105 // allow users to set their own dispatch function for multithreaded dispatch
106 void setIslandDispatchFunction(IslandDispatchFunc func)
107 {
108 m_islandDispatch = func;
109 }
110 };
111
112 #endif //BT_SIMULATION_ISLAND_MANAGER_H
btSimulationIslandManagerMt::setIslandDispatchFunction
void setIslandDispatchFunction(IslandDispatchFunc func)
Definition: btSimulationIslandManagerMt.h:106
btSimulationIslandManagerMt::parallelIslandDispatch
static void parallelIslandDispatch(btAlignedObjectArray< Island * > *islandsPtr, const SolverParams &solverParams)
Definition: btSimulationIslandManagerMt.cpp:574
btSimulationIslandManagerMt::getMinimumSolverBatchSize
int getMinimumSolverBatchSize() const
Definition: btSimulationIslandManagerMt.h:93
btTypedConstraint
TypedConstraint is the baseclass for Bullet constraints and vehicles.
Definition: btTypedConstraint.h:76
btSimulationIslandManager.h
btSimulationIslandManagerMt::setMinimumSolverBatchSize
void setMinimumSolverBatchSize(int sz)
Definition: btSimulationIslandManagerMt.h:97
btSimulationIslandManagerMt::m_freeIslands
btAlignedObjectArray< Island * > m_freeIslands
Definition: btSimulationIslandManagerMt.h:67
btSimulationIslandManagerMt::addManifoldsToIslands
virtual void addManifoldsToIslands(btDispatcher *dispatcher)
Definition: btSimulationIslandManagerMt.cpp:405
btSimulationIslandManagerMt::initIslandPools
virtual void initIslandPools()
Definition: btSimulationIslandManagerMt.cpp:128
btContactSolverInfo
Definition: btContactSolverInfo.h:73
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:77
btSimulationIslandManagerMt::~btSimulationIslandManagerMt
virtual ~btSimulationIslandManagerMt()
Definition: btSimulationIslandManagerMt.cpp:49
btSimulationIslandManagerMt::SolverParams::m_dispatcher
btDispatcher * m_dispatcher
Definition: btSimulationIslandManagerMt.h:56
btSimulationIslandManagerMt::Island::bodyArray
btAlignedObjectArray< btCollisionObject * > bodyArray
Definition: btSimulationIslandManagerMt.h:42
btSimulationIslandManagerMt::SolverParams::m_debugDrawer
btIDebugDraw * m_debugDrawer
Definition: btSimulationIslandManagerMt.h:55
btSimulationIslandManagerMt::m_minimumSolverBatchSize
int m_minimumSolverBatchSize
Definition: btSimulationIslandManagerMt.h:70
btSimulationIslandManagerMt::IslandDispatchFunc
void(* IslandDispatchFunc)(btAlignedObjectArray< Island * > *islands, const SolverParams &solverParams)
Definition: btSimulationIslandManagerMt.h:60
btSimulationIslandManagerMt::Island::append
void append(const Island &other)
Definition: btSimulationIslandManagerMt.cpp:97
btSimulationIslandManagerMt::solveIsland
static void solveIsland(btConstraintSolver *solver, Island &island, const SolverParams &solverParams)
Definition: btSimulationIslandManagerMt.cpp:526
btSimulationIslandManagerMt::SolverParams::m_solverInfo
btContactSolverInfo * m_solverInfo
Definition: btSimulationIslandManagerMt.h:54
btSimulationIslandManagerMt::btSimulationIslandManagerMt
btSimulationIslandManagerMt()
Definition: btSimulationIslandManagerMt.cpp:41
btIDebugDraw
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
Definition: btIDebugDraw.h:27
btSimulationIslandManagerMt::Island::id
int id
Definition: btSimulationIslandManagerMt.h:45
btSimulationIslandManagerMt::buildIslands
virtual void buildIslands(btDispatcher *dispatcher, btCollisionWorld *colWorld)
Definition: btSimulationIslandManagerMt.cpp:262
btSimulationIslandManagerMt::m_lookupIslandFromId
btAlignedObjectArray< Island * > m_lookupIslandFromId
Definition: btSimulationIslandManagerMt.h:68
btSimulationIslandManagerMt::addConstraintsToIslands
virtual void addConstraintsToIslands(btAlignedObjectArray< btTypedConstraint * > &constraints)
Definition: btSimulationIslandManagerMt.cpp:446
btSimulationIslandManagerMt::Island::isSleeping
bool isSleeping
Definition: btSimulationIslandManagerMt.h:46
btSimulationIslandManagerMt::mergeIslands
virtual void mergeIslands()
Definition: btSimulationIslandManagerMt.cpp:465
btSimulationIslandManagerMt::SolverParams::m_solverPool
btConstraintSolver * m_solverPool
Definition: btSimulationIslandManagerMt.h:52
btSimulationIslandManagerMt::getIslandDispatchFunction
IslandDispatchFunc getIslandDispatchFunction() const
Definition: btSimulationIslandManagerMt.h:101
btSimulationIslandManagerMt::SolverParams::m_solverMt
btConstraintSolver * m_solverMt
Definition: btSimulationIslandManagerMt.h:53
btAlignedObjectArray< btCollisionObject * >
btSimulationIslandManagerMt::Island::manifoldArray
btAlignedObjectArray< btPersistentManifold * > manifoldArray
Definition: btSimulationIslandManagerMt.h:43
btSimulationIslandManager
SimulationIslandManager creates and handles simulation islands, using btUnionFind.
Definition: btSimulationIslandManager.h:31
btSimulationIslandManagerMt::addBodiesToIslands
virtual void addBodiesToIslands(btCollisionWorld *collisionWorld)
Definition: btSimulationIslandManagerMt.cpp:360
btSimulationIslandManagerMt::m_allocatedIslands
btAlignedObjectArray< Island * > m_allocatedIslands
Definition: btSimulationIslandManagerMt.h:65
btSimulationIslandManagerMt::buildAndProcessIslands
virtual void buildAndProcessIslands(btDispatcher *dispatcher, btCollisionWorld *collisionWorld, btAlignedObjectArray< btTypedConstraint * > &constraints, const SolverParams &solverParams)
Definition: btSimulationIslandManagerMt.cpp:623
btSimulationIslandManagerMt
SimulationIslandManagerMt – Multithread capable version of SimulationIslandManager Splits the world u...
Definition: btSimulationIslandManagerMt.h:36
btSimulationIslandManagerMt::Island
Definition: btSimulationIslandManagerMt.h:39
btCollisionWorld
CollisionWorld is interface and container for the collision detection.
Definition: btCollisionWorld.h:86
btSimulationIslandManagerMt::SolverParams
Definition: btSimulationIslandManagerMt.h:51
btSimulationIslandManagerMt::m_batchIslandMinBodyCount
int m_batchIslandMinBodyCount
Definition: btSimulationIslandManagerMt.h:71
btSimulationIslandManagerMt::m_batchIsland
Island * m_batchIsland
Definition: btSimulationIslandManagerMt.h:69
btSimulationIslandManagerMt::m_activeIslands
btAlignedObjectArray< Island * > m_activeIslands
Definition: btSimulationIslandManagerMt.h:66
btSimulationIslandManagerMt::allocateIsland
virtual Island * allocateIsland(int id, int numBodies)
Definition: btSimulationIslandManagerMt.cpp:191
btSimulationIslandManagerMt::Island::constraintArray
btAlignedObjectArray< btTypedConstraint * > constraintArray
Definition: btSimulationIslandManagerMt.h:44
btSimulationIslandManagerMt::getIsland
Island * getIsland(int id)
Definition: btSimulationIslandManagerMt.cpp:172
btSimulationIslandManagerMt::serialIslandDispatch
static void serialIslandDispatch(btAlignedObjectArray< Island * > *islandsPtr, const SolverParams &solverParams)
Definition: btSimulationIslandManagerMt.cpp:541
btSimulationIslandManagerMt::m_islandDispatch
IslandDispatchFunc m_islandDispatch
Definition: btSimulationIslandManagerMt.h:72
btConstraintSolver
Definition: btConstraintSolver.h:42