Blender V4.3
btDiscreteDynamicsWorldMt.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2009 Erwin Coumans http://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_DISCRETE_DYNAMICS_WORLD_MT_H
17#define BT_DISCRETE_DYNAMICS_WORLD_MT_H
18
22
33{
34public:
35 // create the solvers for me
36 explicit btConstraintSolverPoolMt(int numSolvers);
37
38 // pass in fully constructed solvers (destructor will delete them)
39 btConstraintSolverPoolMt(btConstraintSolver** solvers, int numSolvers);
40
42
44 virtual btScalar solveGroup(btCollisionObject** bodies,
45 int numBodies,
46 btPersistentManifold** manifolds,
47 int numManifolds,
48 btTypedConstraint** constraints,
50 const btContactSolverInfo& info,
51 btIDebugDraw* debugDrawer,
52 btDispatcher* dispatcher) BT_OVERRIDE;
53
54 virtual void reset() BT_OVERRIDE;
55 virtual btConstraintSolverType getSolverType() const BT_OVERRIDE { return m_solverType; }
56
57private:
58 const static size_t kCacheLineSize = 128;
59 struct ThreadSolver
60 {
61 btConstraintSolver* solver;
62 btSpinMutex mutex;
63 char _cachelinePadding[kCacheLineSize - sizeof(btSpinMutex) - sizeof(void*)]; // keep mutexes from sharing a cache line
64 };
66 btConstraintSolverType m_solverType;
67
68 ThreadSolver* getAndLockThreadSolver();
69 void init(btConstraintSolver** solvers, int numSolvers);
70};
71
83btDiscreteDynamicsWorldMt : public btDiscreteDynamicsWorld
84{
85protected:
86 btConstraintSolver* m_constraintSolverMt;
87
89
91
93 {
97
98 void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
99 {
100 world->createPredictiveContactsInternal(&rigidBodies[iBegin], iEnd - iBegin, timeStep);
101 }
102 };
104
106 {
110
111 void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
112 {
113 world->integrateTransformsInternal(&rigidBodies[iBegin], iEnd - iBegin, timeStep);
114 }
115 };
117
118public:
120
122 btBroadphaseInterface * pairCache,
123 btConstraintSolverPoolMt * solverPool, // Note this should be a solver-pool for multi-threading
124 btConstraintSolver * constraintSolverMt, // single multi-threaded solver for large islands (or NULL)
125 btCollisionConfiguration * collisionConfiguration);
127
128 virtual int stepSimulation(btScalar timeStep, int maxSubSteps, btScalar fixedTimeStep) BT_OVERRIDE;
129};
130
131#endif //BT_DISCRETE_DYNAMICS_WORLD_H
void init()
btConstraintSolverType
btConstraintSolver provides solver interface
BT_DECLARE_ALIGNED_ALLOCATOR()
virtual void solveConstraints(btContactSolverInfo &solverInfo) BT_OVERRIDE
virtual void createPredictiveContacts(btScalar timeStep) BT_OVERRIDE
btDiscreteDynamicsWorldMt(btDispatcher *dispatcher, btBroadphaseInterface *pairCache, btConstraintSolverPoolMt *solverPool, btConstraintSolver *constraintSolverMt, btCollisionConfiguration *collisionConfiguration)
virtual void predictUnconstraintMotion(btScalar timeStep) BT_OVERRIDE
virtual void integrateTransforms(btScalar timeStep) BT_OVERRIDE
virtual int stepSimulation(btScalar timeStep, int maxSubSteps, btScalar fixedTimeStep) BT_OVERRIDE
virtual ~btDiscreteDynamicsWorldMt()
btPersistentManifold()
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
#define ATTRIBUTE_ALIGNED16(a)
Definition btScalar.h:285
btSequentialImpulseConstraintSolverMt int btPersistentManifold int btTypedConstraint ** constraints
btSequentialImpulseConstraintSolverMt int btPersistentManifold int btTypedConstraint int numConstraints
btSequentialImpulseConstraintSolverMt int numBodies
btSequentialImpulseConstraintSolverMt int btPersistentManifold int numManifolds
#define BT_OVERRIDE
Definition btThreads.h:26
virtual void reset() BT_OVERRIDE
clear internal cached data and reset random seed
virtual btConstraintSolverType getSolverType() const BT_OVERRIDE
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
void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
btDiscreteDynamicsWorldMt * world