103 if (rollingFrictionIndex >= 0)
112 cp.m_combinedSpinningFriction,
130 if (axis[1].length2() > axis[0].length2())
135 for (
int i = 0; i < 2; ++i)
148 cp.m_combinedRollingFriction,
201 setupFrictionConstraint(*
frictionConstraint1,
cp.m_lateralFrictionDir1,
solverBodyIdA,
solverBodyIdB,
cp,
rel_pos1,
rel_pos2,
colObj0,
colObj1,
relaxation,
infoGlobal);
205 cp.m_lateralFrictionDir2 =
cp.m_lateralFrictionDir1.cross(
cp.m_normalWorldOnB);
206 cp.m_lateralFrictionDir2.normalize();
209 setupFrictionConstraint(*
frictionConstraint2,
cp.m_lateralFrictionDir2,
solverBodyIdA,
solverBodyIdB,
cp,
rel_pos1,
rel_pos2,
colObj0,
colObj1,
relaxation,
infoGlobal);
218 setupFrictionConstraint(*
frictionConstraint1,
cp.m_lateralFrictionDir1,
solverBodyIdA,
solverBodyIdB,
cp,
rel_pos1,
rel_pos2,
colObj0,
colObj1,
relaxation,
infoGlobal);
224 setupFrictionConstraint(*
frictionConstraint2,
cp.m_lateralFrictionDir2,
solverBodyIdA,
solverBodyIdB,
cp,
rel_pos1,
rel_pos2,
colObj0,
colObj1,
relaxation,
infoGlobal);
235 setupFrictionConstraint(*
frictionConstraint1,
cp.m_lateralFrictionDir1,
solverBodyIdA,
solverBodyIdB,
cp,
rel_pos1,
rel_pos2,
colObj0,
colObj1,
relaxation,
infoGlobal,
cp.m_contactMotion1,
cp.m_frictionCFM);
238 setupFrictionConstraint(*
frictionConstraint2,
cp.m_lateralFrictionDir2,
solverBodyIdA,
solverBodyIdB,
cp,
rel_pos1,
rel_pos2,
colObj0,
colObj1,
relaxation,
infoGlobal,
cp.m_contactMotion2,
cp.m_frictionCFM);
391 BT_PROFILE(
"internalCollectContactManifoldCachedInfo");
415 for (
int j = 0;
j <
manifold->getNumContacts();
j++)
419 if (
cp.getDistance() <=
manifold->getContactProcessingThreshold())
452 BT_PROFILE(
"internalAllocContactConstraints");
459 int rollingFrictionIndex =
cachedInfo.rollingFrictionIndex;
460 for (
int i = 0; i <
cachedInfo.numTouchingContacts; i++)
481 for (
int i = 0; i < 3; i++)
484 rollingFrictionIndex++;
541 for (
int i = 0; i <
cachedInfo.numTouchingContacts; ++i)
613 fb->m_appliedTorqueBodyA.setZero();
614 fb->m_appliedForceBodyB.setZero();
615 fb->m_appliedTorqueBodyB.setZero();
621 info1.m_numConstraintRows = 0;
712 for (
int i = 0; i < numConstraints; i++)
719 if (
info1.m_numConstraintRows)
727 params.m_solverConstraint = -1;
885 BT_PROFILE(
"ContactSplitPenetrationImpulseSolverLoop");
898 BT_PROFILE(
"solveGroupCacheFriendlySplitImpulseIterations");
924#ifdef VERBOSE_RESIDUAL_PRINTF
960 for (
int j = 0;
j < numConstraints;
j++)
1172 for (
int ii = 1;
ii <
bc.m_phaseOrder.size(); ++
ii)
1309 BT_PROFILE(
"resolveAllContactFrictionConstraints");
1348 BT_PROFILE(
"resolveAllContactConstraintsInterleaved");
1387 BT_PROFILE(
"resolveAllRollingFrictionConstraints");
@ BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED
const T & btMax(const T &a, const T &b)
@ BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_BODY
@ BT_ENABLE_GYROSCOPIC_FORCE_EXPLICIT
BT_ENABLE_GYROPSCOPIC_FORCE flags is enabled by default in Bullet 2.83 and onwards.
@ BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_WORLD
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btScalar btSqrt(btScalar y)
static T sum(const btAlignedObjectArray< T > &items)
btScalar btParallelSum(int iBegin, int iEnd, int grainSize, const btIParallelSumBody &body)
bool btThreadsAreRunning()
void btParallelFor(int iBegin, int iEnd, int grainSize, const btIParallelForBody &body)
void btPlaneSpace1(const T &n, T &p, T &q)
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
void resizeNoInitialize(int newsize)
resize changes the number of elements in the array.
int size() const
return the number of elements in the array
void resize(int newsize, const T &fillData=T())
T & expand(const T &fillValue=T())
int capacity() const
return the pre-allocated (reserved) elements, this is at least as large as the total number of elemen...
btCollisionObject can be used to manage collision detection objects.
bool isStaticOrKinematicObject() const
int getWorldArrayIndex() const
void setCompanionId(int id)
bool isKinematicObject() const
@ CF_ANISOTROPIC_ROLLING_FRICTION
@ CF_ANISOTROPIC_FRICTION
int getCompanionId() const
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
ManifoldContactPoint collects and maintains persistent contactpoints.
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
The btRigidBody is the main class for rigid body objects.
btScalar getInvMass() const
btVector3 computeGyroscopicImpulseImplicit_World(btScalar dt) const
perform implicit force computation in world space
btVector3 computeGyroscopicImpulseImplicit_Body(btScalar step) const
perform implicit force computation in body space (inertial frame)
static const btRigidBody * upcast(const btCollisionObject *colObj)
to keep collision detection and dynamics separate we don't store a rigidbody pointer but a rigidbody ...
const btMatrix3x3 & getInvInertiaTensorWorld() const
btVector3 computeGyroscopicForceExplicit(btScalar maxGyroscopicForce) const
explicit version is best avoided, it gains energy
btSequentialImpulseConstraintSolverMt
virtual void setupBatchedContactConstraints()
void internalCollectContactManifoldCachedInfo(btContactManifoldCachedInfo *cachedInfoArray, btPersistentManifold **manifoldPtr, int numManifolds, const btContactSolverInfo &infoGlobal)
virtual btScalar resolveAllRollingFrictionConstraints()
void internalWriteBackBodies(int iBegin, int iEnd, const btContactSolverInfo &infoGlobal)
void internalAllocContactConstraints(const btContactManifoldCachedInfo *cachedInfoArray, int numManifolds)
void internalConvertMultipleJoints(const btAlignedObjectArray< JointParams > &jointParamsArray, btTypedConstraint **constraints, int iBegin, int iEnd, const btContactSolverInfo &infoGlobal)
btBatchedConstraints m_batchedJointConstraints
btSpinMutex m_kinematicBodyUniqueIdToSolverBodyTableMutex
btSequentialImpulseConstraintSolverMt()
virtual btScalar resolveAllJointConstraints(int iteration)
void internalWriteBackContacts(int iBegin, int iEnd, const btContactSolverInfo &infoGlobal)
virtual void randomizeConstraintOrdering(int iteration, int numIterations)
btAlignedObjectArray< int > m_rollingFrictionIndexTable
static btBatchedConstraints::BatchingMethod s_contactBatchingMethod
int m_numFrictionDirections
int getOrInitSolverBodyThreadsafe(btCollisionObject &body, btScalar timeStep)
virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifoldPtr, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal, btIDebugDraw *debugDrawer) BT_OVERRIDE
virtual void convertBodies(btCollisionObject **bodies, int numBodies, const btContactSolverInfo &infoGlobal) BT_OVERRIDE
virtual void solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifoldPtr, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal, btIDebugDraw *debugDrawer) BT_OVERRIDE
btScalar resolveMultipleContactRollingFrictionConstraints(const btAlignedObjectArray< int > &consIndices, int batchBegin, int batchEnd)
btBatchedConstraints m_batchedContactConstraints
btScalar resolveMultipleContactConstraintsInterleaved(const btAlignedObjectArray< int > &contactIndices, int batchBegin, int batchEnd)
virtual void convertJoints(btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal) BT_OVERRIDE
virtual btScalar resolveAllContactFrictionConstraints()
void internalInitMultipleJoints(btTypedConstraint **constraints, int iBegin, int iEnd)
void randomizeBatchedConstraintOrdering(btBatchedConstraints *batchedConstraints)
virtual void setupBatchedJointConstraints()
virtual btScalar solveSingleIteration(int iteration, btCollisionObject **bodies, int numBodies, btPersistentManifold **manifoldPtr, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal, btIDebugDraw *debugDrawer) BT_OVERRIDE
void internalWriteBackJoints(int iBegin, int iEnd, const btContactSolverInfo &infoGlobal)
void internalSetupContactConstraints(int iContactConstraint, const btContactSolverInfo &infoGlobal)
btScalar resolveMultipleContactSplitPenetrationImpulseConstraints(const btAlignedObjectArray< int > &consIndices, int batchBegin, int batchEnd)
btAlignedObjectArray< char > m_scratchMemory
static bool s_allowNestedParallelForLoops
virtual btScalar resolveAllContactConstraints()
virtual ~btSequentialImpulseConstraintSolverMt()
btScalar resolveMultipleJointConstraints(const btAlignedObjectArray< int > &consIndices, int batchBegin, int batchEnd, int iteration)
void allocAllContactConstraints(btPersistentManifold **manifoldPtr, int numManifolds, const btContactSolverInfo &infoGlobal)
void setupAllContactConstraints(const btContactSolverInfo &infoGlobal)
static int s_minBatchSize
btSpinMutex m_bodySolverArrayMutex
virtual btScalar solveGroupCacheFriendlyFinish(btCollisionObject **bodies, int numBodies, const btContactSolverInfo &infoGlobal) BT_OVERRIDE
virtual btScalar resolveAllContactConstraintsInterleaved()
btScalar resolveMultipleContactFrictionConstraints(const btAlignedObjectArray< int > &consIndices, int batchBegin, int batchEnd)
virtual void convertContacts(btPersistentManifold **manifoldPtr, int numManifolds, const btContactSolverInfo &infoGlobal) BT_OVERRIDE
btScalar resolveMultipleContactConstraints(const btAlignedObjectArray< int > &consIndices, int batchBegin, int batchEnd)
static int s_maxBatchSize
bool m_useObsoleteJointConstraints
void internalConvertBodies(btCollisionObject **bodies, int iBegin, int iEnd, const btContactSolverInfo &infoGlobal)
static int s_minimumContactManifoldsForBatching
static btBatchedConstraints::BatchingMethod s_jointBatchingMethod
void initSolverBody(btSolverBody *solverBody, btCollisionObject *collisionObject, btScalar timeStep)
btConstraintArray m_tmpSolverContactConstraintPool
void writeBackJoints(int iBegin, int iEnd, const btContactSolverInfo &infoGlobal)
btConstraintArray m_tmpSolverContactFrictionConstraintPool
virtual void convertJoints(btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal)
void convertJoint(btSolverConstraint *currentConstraintRow, btTypedConstraint *constraint, const btTypedConstraint::btConstraintInfo1 &info1, int solverBodyIdA, int solverBodyIdB, const btContactSolverInfo &infoGlobal)
virtual void convertContacts(btPersistentManifold **manifoldPtr, int numManifolds, const btContactSolverInfo &infoGlobal)
btScalar resolveSingleConstraintRowLowerLimit(btSolverBody &bodyA, btSolverBody &bodyB, const btSolverConstraint &contactConstraint)
static void applyAnisotropicFriction(btCollisionObject *colObj, btVector3 &frictionDirection, int frictionMode)
btScalar resolveSingleConstraintRowGeneric(btSolverBody &bodyA, btSolverBody &bodyB, const btSolverConstraint &contactConstraint)
void setupTorsionalFrictionConstraint(btSolverConstraint &solverConstraint, const btVector3 &normalAxis, int solverBodyIdA, int solverBodyIdB, btManifoldPoint &cp, btScalar combinedTorsionalFriction, const btVector3 &rel_pos1, const btVector3 &rel_pos2, btCollisionObject *colObj0, btCollisionObject *colObj1, btScalar relaxation, btScalar desiredVelocity=0., btScalar cfmSlip=0.)
btAlignedObjectArray< btSolverBody > m_tmpSolverBodyPool
btAlignedObjectArray< btTypedConstraint::btConstraintInfo1 > m_tmpConstraintSizesPool
btAlignedObjectArray< int > m_orderTmpConstraintPool
void writeBackBodies(int iBegin, int iEnd, const btContactSolverInfo &infoGlobal)
btAlignedObjectArray< int > m_kinematicBodyUniqueIdToSolverBodyTable
virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifoldPtr, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal, btIDebugDraw *debugDrawer)
void setupFrictionConstraint(btSolverConstraint &solverConstraint, const btVector3 &normalAxis, int solverBodyIdA, int solverBodyIdB, btManifoldPoint &cp, const btVector3 &rel_pos1, const btVector3 &rel_pos2, btCollisionObject *colObj0, btCollisionObject *colObj1, btScalar relaxation, const btContactSolverInfo &infoGlobal, btScalar desiredVelocity=0., btScalar cfmSlip=0.)
btConstraintArray m_tmpSolverNonContactConstraintPool
btConstraintArray m_tmpSolverContactRollingFrictionConstraintPool
void setFrictionConstraintImpulse(btSolverConstraint &solverConstraint, int solverBodyIdA, int solverBodyIdB, btManifoldPoint &cp, const btContactSolverInfo &infoGlobal)
int getOrInitSolverBody(btCollisionObject &body, btScalar timeStep)
void writeBackContacts(int iBegin, int iEnd, const btContactSolverInfo &infoGlobal)
virtual btScalar solveSingleIteration(int iteration, btCollisionObject **bodies, int numBodies, btPersistentManifold **manifoldPtr, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal, btIDebugDraw *debugDrawer)
btScalar resolveSplitPenetrationImpulse(btSolverBody &bodyA, btSolverBody &bodyB, const btSolverConstraint &contactConstraint)
void setupContactConstraint(btSolverConstraint &solverConstraint, int solverBodyIdA, int solverBodyIdB, btManifoldPoint &cp, const btContactSolverInfo &infoGlobal, btScalar &relaxation, const btVector3 &rel_pos1, const btVector3 &rel_pos2)
TypedConstraint is the baseclass for Bullet constraints and vehicles.
btVector3 can be used to represent 3D points and vectors.
btScalar dot(const btVector3 &v) const
Return the dot product.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
btSequentialImpulseConstraintSolverMt * m_solver
btCollisionObject ** m_bodies
void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
ConvertBodiesLoop(btSequentialImpulseConstraintSolverMt *solver, btCollisionObject **bodies, int numBodies, const btContactSolverInfo &infoGlobal)
const btContactSolverInfo & m_infoGlobal
btSequentialImpulseConstraintSolverMt * m_solver
const btContactSolverInfo & m_infoGlobal
btTypedConstraint ** m_srcConstraints
const btAlignedObjectArray< btSequentialImpulseConstraintSolverMt::JointParams > & m_jointParamsArray
void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
ConvertJointsLoop(btSequentialImpulseConstraintSolverMt *solver, const btAlignedObjectArray< btSequentialImpulseConstraintSolverMt::JointParams > &jointParamsArray, btTypedConstraint **srcConstraints, const btContactSolverInfo &infoGlobal)
btTypedConstraint ** m_constraints
void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
InitJointsLoop(btSequentialImpulseConstraintSolverMt *solver, btTypedConstraint **constraints)
btSequentialImpulseConstraintSolverMt * m_solver
JointSolverLoop(btSequentialImpulseConstraintSolverMt *solver, const btBatchedConstraints *bc, int iteration)
btScalar sumLoop(int iBegin, int iEnd) const BT_OVERRIDE
btSequentialImpulseConstraintSolverMt * m_solver
const btBatchedConstraints * m_bc
void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
const btContactSolverInfo * m_infoGlobal
WriteBodiesLoop(btSequentialImpulseConstraintSolverMt *solver, const btContactSolverInfo &infoGlobal)
btSequentialImpulseConstraintSolverMt * m_solver
WriteJointsLoop(btSequentialImpulseConstraintSolverMt *solver, const btContactSolverInfo &infoGlobal)
const btContactSolverInfo * m_infoGlobal
void forLoop(int iBegin, int iEnd) const BT_OVERRIDE
btSequentialImpulseConstraintSolverMt * m_solver
btAlignedObjectArray< Range > m_batches
btAlignedObjectArray< int > m_constraintIndices
void setup(btConstraintArray *constraints, const btAlignedObjectArray< btSolverBody > &bodies, BatchingMethod batchingMethod, int minBatchSize, int maxBatchSize, btAlignedObjectArray< char > *scratchMemory)
btIDebugDraw * m_debugDrawer
@ BATCHING_METHOD_SPATIAL_GRID_2D
btVector3 m_appliedForceBodyA
The btSolverBody is an internal datastructure for the constraint solver. Only necessary data is packe...
1D constraint along a normal axis between bodyA and bodyB. It can be combined to solve contact and fr...