Blender  V3.3
btSequentialImpulseConstraintSolverMt.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_SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_MT_H
17 #define BT_SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_MT_H
18 
20 #include "btBatchedConstraints.h"
21 #include "LinearMath/btThreads.h"
22 
58 {
59 public:
64 
65  // temp struct used to collect info from persistent manifolds into a cache-friendly struct using multiple threads
67  {
68  static const int MAX_NUM_CONTACT_POINTS = 4;
69 
71  int solverBodyIds[2];
76  };
77  // temp struct used for setting up joint constraints in parallel
78  struct JointParams
79  {
83  };
84  void internalInitMultipleJoints(btTypedConstraint * *constraints, int iBegin, int iEnd);
86 
87  // parameters to control batching
88  static bool s_allowNestedParallelForLoops; // whether to allow nested parallel operations
89  static int s_minimumContactManifoldsForBatching; // don't even try to batch if fewer manifolds than this
92  static int s_minBatchSize; // desired number of constraints per batch
93  static int s_maxBatchSize;
94 
95 protected:
96  static const int CACHE_LINE_SIZE = 64;
97 
104  btAlignedObjectArray<int> m_rollingFrictionIndexTable; // lookup table mapping contact index to rolling friction index
106  char m_antiFalseSharingPadding[CACHE_LINE_SIZE]; // padding to keep mutexes in separate cachelines
109 
110  virtual void randomizeConstraintOrdering(int iteration, int numIterations);
111  virtual btScalar resolveAllJointConstraints(int iteration);
116 
117  virtual void setupBatchedContactConstraints();
118  virtual void setupBatchedJointConstraints();
122 
126  void randomizeBatchedConstraintOrdering(btBatchedConstraints * batchedConstraints);
127 
128 public:
130 
133 
134  btScalar resolveMultipleJointConstraints(const btAlignedObjectArray<int>& consIndices, int batchBegin, int batchEnd, int iteration);
135  btScalar resolveMultipleContactConstraints(const btAlignedObjectArray<int>& consIndices, int batchBegin, int batchEnd);
136  btScalar resolveMultipleContactSplitPenetrationImpulseConstraints(const btAlignedObjectArray<int>& consIndices, int batchBegin, int batchEnd);
137  btScalar resolveMultipleContactFrictionConstraints(const btAlignedObjectArray<int>& consIndices, int batchBegin, int batchEnd);
138  btScalar resolveMultipleContactRollingFrictionConstraints(const btAlignedObjectArray<int>& consIndices, int batchBegin, int batchEnd);
139  btScalar resolveMultipleContactConstraintsInterleaved(const btAlignedObjectArray<int>& contactIndices, int batchBegin, int batchEnd);
140 
143  void internalSetupContactConstraints(int iContactConstraint, const btContactSolverInfo& infoGlobal);
144  void internalConvertBodies(btCollisionObject * *bodies, int iBegin, int iEnd, const btContactSolverInfo& infoGlobal);
145  void internalWriteBackContacts(int iBegin, int iEnd, const btContactSolverInfo& infoGlobal);
146  void internalWriteBackJoints(int iBegin, int iEnd, const btContactSolverInfo& infoGlobal);
147  void internalWriteBackBodies(int iBegin, int iEnd, const btContactSolverInfo& infoGlobal);
148 };
149 
150 #endif //BT_SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_MT_H
btCollisionObject
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
virtual void setupBatchedContactConstraints()
void internalCollectContactManifoldCachedInfo(btContactManifoldCachedInfo *cachedInfoArray, btPersistentManifold **manifoldPtr, int numManifolds, const btContactSolverInfo &infoGlobal)
virtual btScalar resolveAllRollingFrictionConstraints()
BT_DECLARE_ALIGNED_ALLOCATOR()
void internalWriteBackBodies(int iBegin, int iEnd, const btContactSolverInfo &infoGlobal)
btBatchedConstraints m_batchedContactConstraints
btAlignedObjectArray< int > m_rollingFrictionIndexTable
void internalAllocContactConstraints(const btContactManifoldCachedInfo *cachedInfoArray, int numManifolds)
void internalConvertMultipleJoints(const btAlignedObjectArray< JointParams > &jointParamsArray, btTypedConstraint **constraints, int iBegin, int iEnd, const btContactSolverInfo &infoGlobal)
btAlignedObjectArray< btContactManifoldCachedInfo > m_manifoldCachedInfoArray
virtual btScalar resolveAllJointConstraints(int iteration)
void internalWriteBackContacts(int iBegin, int iEnd, const btContactSolverInfo &infoGlobal)
virtual void randomizeConstraintOrdering(int iteration, int numIterations)
btSpinMutex m_kinematicBodyUniqueIdToSolverBodyTableMutex
btBatchedConstraints m_batchedJointConstraints
static btBatchedConstraints::BatchingMethod s_contactBatchingMethod
static const int CACHE_LINE_SIZE
int getOrInitSolverBodyThreadsafe(btCollisionObject &body, btScalar timeStep)
btSequentialImpulseConstraintSolverMt int btPersistentManifold int btTypedConstraint ** constraints
btScalar resolveMultipleContactRollingFrictionConstraints(const btAlignedObjectArray< int > &consIndices, int batchBegin, int batchEnd)
btScalar resolveMultipleContactConstraintsInterleaved(const btAlignedObjectArray< int > &contactIndices, int batchBegin, int batchEnd)
btSequentialImpulseConstraintSolverMt int btPersistentManifold ** manifoldPtr
char m_antiFalseSharingPadding[CACHE_LINE_SIZE]
virtual btScalar resolveAllContactFrictionConstraints()
void internalInitMultipleJoints(btTypedConstraint **constraints, int iBegin, int iEnd)
btSequentialImpulseConstraintSolverMt int btPersistentManifold int btTypedConstraint int const btContactSolverInfo btIDebugDraw *debugDrawer BT_OVERRIDE
btSpinMutex m_bodySolverArrayMutex
void randomizeBatchedConstraintOrdering(btBatchedConstraints *batchedConstraints)
btSequentialImpulseConstraintSolverMt int btPersistentManifold int btTypedConstraint int numConstraints
virtual void setupBatchedJointConstraints()
virtual void convertBodies(btCollisionObject **bodies, int numBodies, const btContactSolverInfo &infoGlobal) BT_OVERRIDE
void internalWriteBackJoints(int iBegin, int iEnd, const btContactSolverInfo &infoGlobal)
virtual void convertJoints(btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal) BT_OVERRIDE
btAlignedObjectArray< char > m_scratchMemory
btSequentialImpulseConstraintSolverMt int numBodies
void internalSetupContactConstraints(int iContactConstraint, const btContactSolverInfo &infoGlobal)
virtual void convertContacts(btPersistentManifold **manifoldPtr, int numManifolds, const btContactSolverInfo &infoGlobal) BT_OVERRIDE
virtual btScalar solveGroupCacheFriendlyFinish(btCollisionObject **bodies, int numBodies, const btContactSolverInfo &infoGlobal) BT_OVERRIDE
btScalar resolveMultipleContactSplitPenetrationImpulseConstraints(const btAlignedObjectArray< int > &consIndices, int batchBegin, int batchEnd)
static bool s_allowNestedParallelForLoops
btSequentialImpulseConstraintSolverMt int btPersistentManifold int btTypedConstraint int const btContactSolverInfo & infoGlobal
virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifoldPtr, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal, btIDebugDraw *debugDrawer) BT_OVERRIDE
virtual btScalar resolveAllContactConstraints()
virtual ~btSequentialImpulseConstraintSolverMt()
virtual btScalar solveSingleIteration(int iteration, btCollisionObject **bodies, int numBodies, btPersistentManifold **manifoldPtr, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal, btIDebugDraw *debugDrawer) BT_OVERRIDE
btScalar resolveMultipleJointConstraints(const btAlignedObjectArray< int > &consIndices, int batchBegin, int batchEnd, int iteration)
btSequentialImpulseConstraintSolverMt int btPersistentManifold int numManifolds
void allocAllContactConstraints(btPersistentManifold **manifoldPtr, int numManifolds, const btContactSolverInfo &infoGlobal)
void setupAllContactConstraints(const btContactSolverInfo &infoGlobal)
virtual btScalar resolveAllContactConstraintsInterleaved()
btScalar resolveMultipleContactFrictionConstraints(const btAlignedObjectArray< int > &consIndices, int batchBegin, int batchEnd)
btScalar resolveMultipleContactConstraints(const btAlignedObjectArray< int > &consIndices, int batchBegin, int batchEnd)
void internalConvertBodies(btCollisionObject **bodies, int iBegin, int iEnd, const btContactSolverInfo &infoGlobal)
static int s_minimumContactManifoldsForBatching
static btBatchedConstraints::BatchingMethod s_jointBatchingMethod
virtual void solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifoldPtr, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal, btIDebugDraw *debugDrawer)
btTypedConstraint(btTypedConstraintType type, btRigidBody &rbA)
bool contactHasRollingFriction[MAX_NUM_CONTACT_POINTS]
btManifoldPoint * contactPoints[MAX_NUM_CONTACT_POINTS]