Bullet Collision Detection & Physics Library
btSimulationIslandManagerMt.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. 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
24class btIDebugDraw;
25
36{
37public:
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
47
48 void append(const Island& other); // add bodies, manifolds, constraints to my own
49 };
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
64protected:
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
82public:
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
CollisionWorld is interface and container for the collision detection.
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:77
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
Definition: btIDebugDraw.h:27
SimulationIslandManagerMt – Multithread capable version of SimulationIslandManager Splits the world u...
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.
TypedConstraint is the baseclass for Bullet constraints and vehicles.
btAlignedObjectArray< btTypedConstraint * > constraintArray
btAlignedObjectArray< btCollisionObject * > bodyArray
btAlignedObjectArray< btPersistentManifold * > manifoldArray