Bullet Collision Detection & Physics Library
btDiscreteDynamicsWorldMt.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
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 
17 #ifndef BT_DISCRETE_DYNAMICS_WORLD_MT_H
18 #define BT_DISCRETE_DYNAMICS_WORLD_MT_H
19 
23 
25 
36 {
37 public:
38  // create the solvers for me
39  explicit btConstraintSolverPoolMt( int numSolvers );
40 
41  // pass in fully constructed solvers (destructor will delete them)
42  btConstraintSolverPoolMt( btConstraintSolver** solvers, int numSolvers );
43 
44  virtual ~btConstraintSolverPoolMt();
45 
47  virtual btScalar solveGroup( btCollisionObject** bodies,
48  int numBodies,
49  btPersistentManifold** manifolds,
50  int numManifolds,
51  btTypedConstraint** constraints,
52  int numConstraints,
53  const btContactSolverInfo& info,
54  btIDebugDraw* debugDrawer,
55  btDispatcher* dispatcher
56  ) BT_OVERRIDE;
57 
58  virtual void reset() BT_OVERRIDE;
60 
61 private:
62  const static size_t kCacheLineSize = 128;
63  struct ThreadSolver
64  {
67  char _cachelinePadding[ kCacheLineSize - sizeof( btSpinMutex ) - sizeof( void* ) ]; // keep mutexes from sharing a cache line
68  };
71 
73  void init( btConstraintSolver** solvers, int numSolvers );
74 };
75 
76 
77 
89 {
90 protected:
92 
93  virtual void solveConstraints(btContactSolverInfo& solverInfo) BT_OVERRIDE;
94 
95  virtual void predictUnconstraintMotion( btScalar timeStep ) BT_OVERRIDE;
96 
98  {
102 
103  void forLoop( int iBegin, int iEnd ) const BT_OVERRIDE
104  {
105  world->createPredictiveContactsInternal( &rigidBodies[ iBegin ], iEnd - iBegin, timeStep );
106  }
107  };
108  virtual void createPredictiveContacts( btScalar timeStep ) BT_OVERRIDE;
109 
111  {
115 
116  void forLoop( int iBegin, int iEnd ) const BT_OVERRIDE
117  {
118  world->integrateTransformsInternal( &rigidBodies[ iBegin ], iEnd - iBegin, timeStep );
119  }
120  };
121  virtual void integrateTransforms( btScalar timeStep ) BT_OVERRIDE;
122 
123 public:
125 
127  btBroadphaseInterface* pairCache,
128  btConstraintSolverPoolMt* constraintSolver, // Note this should be a solver-pool for multi-threading
129  btCollisionConfiguration* collisionConfiguration
130  );
131  virtual ~btDiscreteDynamicsWorldMt();
132 };
133 
134 #endif //BT_DISCRETE_DYNAMICS_WORLD_H
char _cachelinePadding[kCacheLineSize - sizeof(btSpinMutex) - sizeof(void *)]
virtual btScalar solveGroup(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifolds, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &info, btIDebugDraw *debugDrawer, btDispatcher *dispatcher) BT_OVERRIDE
solve a group of constraints
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
btConstraintSolverPoolMt - masquerades as a constraint solver, but really it is a threadsafe pool of ...
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
btConstraintSolverType
btConstraintSolver provides solver interface
void integrateTransformsInternal(btRigidBody **bodies, int numBodies, btScalar timeStep)
btDiscreteDynamicsWorld provides discrete rigid body simulation those classes replace the obsolete Cc...
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size...
void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
btSpinMutex – lightweight spin-mutex implemented with atomic ops, never puts a thread to sleep beca...
Definition: btThreads.h:45
void init(btConstraintSolver **solvers, int numSolvers)
virtual void reset() BT_OVERRIDE
clear internal cached data and reset random seed
#define BT_OVERRIDE
Definition: btThreads.h:28
ThreadSolver * getAndLockThreadSolver()
btConstraintSolverPoolMt
btCollisionObject can be used to manage collision detection objects.
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
Definition: btIDebugDraw.h:29
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:62
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs...
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:82
btDiscreteDynamicsWorldMt – a version of DiscreteDynamicsWorld with some minor changes to support s...
btAlignedObjectArray< ThreadSolver > m_solvers
TypedConstraint is the baseclass for Bullet constraints and vehicles.
#define BT_DECLARE_ALIGNED_ALLOCATOR()
Definition: btScalar.h:403
btConstraintSolverType m_solverType
void createPredictiveContactsInternal(btRigidBody **bodies, int numBodies, btScalar timeStep)
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:75
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:292
InplaceSolverIslandCallbackMt * m_solverIslandCallbackMt
virtual btConstraintSolverType getSolverType() const BT_OVERRIDE