60 int firstContactConstraintOffset=dindex;
71 if (numFrictionPerContact==2)
158 int n = numConstraintRows;
161 m_b.resize(numConstraintRows);
164 for (
int i=0;i<numConstraintRows ;i++)
178 m_lo.resize(numConstraintRows);
179 m_hi.resize(numConstraintRows);
184 for (
int i=0;i<numConstraintRows;i++)
205 bodyJointNodeArray.
resize(numBodies,-1);
222 JinvM3.resize(2*m,8);
254 slotA =jointNodeArray.
size();
256 int prevSlot = bodyJointNodeArray[sbA];
257 bodyJointNodeArray[sbA] = slotA;
258 jointNodeArray[slotA].nextJointNodeIndex = prevSlot;
259 jointNodeArray[slotA].jointIndex = c;
260 jointNodeArray[slotA].constraintRowIndex = i;
261 jointNodeArray[slotA].otherBodyIndex = orgBodyB ? sbB : -1;
263 for (
int row=0;row<numRows;row++,cur++)
268 for (
int r=0;r<3;r++)
272 JinvM3.setElem(cur,r,normalInvMass[r]);
273 JinvM3.setElem(cur,r+4,relPosCrossNormalInvInertia[r]);
276 JinvM3.setElem(cur,3,0);
278 JinvM3.setElem(cur,7,0);
290 slotB =jointNodeArray.
size();
292 int prevSlot = bodyJointNodeArray[sbB];
293 bodyJointNodeArray[sbB] = slotB;
294 jointNodeArray[slotB].nextJointNodeIndex = prevSlot;
295 jointNodeArray[slotB].jointIndex = c;
296 jointNodeArray[slotB].otherBodyIndex = orgBodyA ? sbA : -1;
297 jointNodeArray[slotB].constraintRowIndex = i;
300 for (
int row=0;row<numRows;row++,cur++)
305 for (
int r=0;r<3;r++)
309 JinvM3.setElem(cur,r,normalInvMassB[r]);
310 JinvM3.setElem(cur,r+4,relPosInvInertiaB[r]);
313 JinvM3.setElem(cur,3,0);
315 JinvM3.setElem(cur,7,0);
330 const btScalar* JinvM = JinvM3.getBufferPointer();
332 const btScalar* Jptr = J3.getBufferPointer();
356 const btScalar *JinvMrow = JinvM + 2*8*(size_t)row__;
359 int startJointNodeA = bodyJointNodeArray[sbA];
360 while (startJointNodeA>=0)
362 int j0 = jointNodeArray[startJointNodeA].jointIndex;
363 int cr0 = jointNodeArray[startJointNodeA].constraintRowIndex;
370 m_A.multiplyAdd2_p8r ( JinvMrow,
371 Jptr + 2*8*(
size_t)ofs[j0] + ofsother, numRows, numRowsOther, row__,ofs[j0]);
373 startJointNodeA = jointNodeArray[startJointNodeA].nextJointNodeIndex;
378 int startJointNodeB = bodyJointNodeArray[sbB];
379 while (startJointNodeB>=0)
381 int j1 = jointNodeArray[startJointNodeB].jointIndex;
382 int cj1 = jointNodeArray[startJointNodeB].constraintRowIndex;
388 m_A.multiplyAdd2_p8r ( JinvMrow + 8*(
size_t)numRows,
389 Jptr + 2*8*(
size_t)ofs[j1] + ofsother, numRows, numRowsOther, row__,ofs[j1]);
391 startJointNodeB = jointNodeArray[startJointNodeB].nextJointNodeIndex;
404 for (;row__<numJointRows;)
415 const btScalar *JinvMrow = JinvM + 2*8*(size_t)row__;
416 const btScalar *Jrow = Jptr + 2*8*(size_t)row__;
417 m_A.multiply2_p8r (JinvMrow, Jrow, infom, infom, row__,row__);
420 m_A.multiplyAdd2_p8r (JinvMrow + 8*(
size_t)infom, Jrow + 8*(
size_t)infom, infom, infom, row__,row__);
432 for (
int i=0; i<
m_A.rows(); ++i)
434 float cfm = 0.00001f;
442 m_A.copyLowerToUpperTriangle();
447 m_x.resize(numConstraintRows);
472 m_b.resize(numConstraintRows);
476 for (
int i=0;i<numConstraintRows ;i++)
487 Minv.resize(6*numBodies,6*numBodies);
489 for (
int i=0;i<numBodies;i++)
493 setElem(Minv,i*6+0,i*6+0,invMass[0]);
494 setElem(Minv,i*6+1,i*6+1,invMass[1]);
495 setElem(Minv,i*6+2,i*6+2,invMass[2]);
498 for (
int r=0;r<3;r++)
499 for (
int c=0;c<3;c++)
504 J.resize(numConstraintRows,6*numBodies);
507 m_lo.resize(numConstraintRows);
508 m_hi.resize(numConstraintRows);
510 for (
int i=0;i<numConstraintRows;i++)
539 J_transpose= J.transpose();
551 m_A = tmp*J_transpose;
559 for (
int i=0; i<
m_A.rows(); ++i)
566 m_x.resize(numConstraintRows);
btScalar getInvMass() const
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
void push_back(const T &_Val)
btConstraintArray m_tmpSolverContactFrictionConstraintPool
virtual void createMLCP(const btContactSolverInfo &infoGlobal)
void internalApplyImpulse(const btVector3 &linearComponent, const btVector3 &angularComponent, const btScalar impulseMagnitude)
1D constraint along a normal axis between bodyA and bodyB. It can be combined to solve contact and fr...
void resizeNoInitialize(int newsize)
resize changes the number of elements in the array.
virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifoldPtr, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal, btIDebugDraw *debugDrawer)
btConstraintArray m_allConstraintArray
btVector3 m_angularComponentA
btAlignedObjectArray< btSolverBody > m_tmpSolverBodyPool
btMLCPSolver(btMLCPSolverInterface *solver)
original version written by Erwin Coumans, October 2013
int size() const
return the number of elements in the array
virtual bool solveMLCP(const btMatrixXu &A, const btVectorXu &b, btVectorXu &x, const btVectorXu &lo, const btVectorXu &hi, const btAlignedObjectArray< int > &limitDependency, int numIterations, bool useSparsity=true)=0
original version written by Erwin Coumans, October 2013
btConstraintArray m_tmpSolverContactConstraintPool
btCollisionObject can be used to manage collision detection objects.
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
The btRigidBody is the main class for rigid body objects.
btVector3 m_angularComponentB
btVectorXu m_bSplit
when using 'split impulse' we solve two separate (M)LCPs
const btVector3 & internalGetInvMass() const
virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifoldPtr, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal, btIDebugDraw *debugDrawer)
btVector3 can be used to represent 3D points and vectors.
btMLCPSolverInterface * m_solver
virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifoldPtr, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal, btIDebugDraw *debugDrawer)
btSimdScalar m_appliedPushImpulse
The btSolverBody is an internal datastructure for the constraint solver. Only necessary data is packe...
btAlignedObjectArray< btTypedConstraint::btConstraintInfo1 > m_tmpConstraintSizesPool
TypedConstraint is the baseclass for Bullet constraints and vehicles.
void resize(int newsize, const T &fillData=T())
void internalApplyPushImpulse(const btVector3 &linearComponent, const btVector3 &angularComponent, btScalar impulseMagnitude)
virtual bool solveMLCP(const btContactSolverInfo &infoGlobal)
bool interleaveContactAndFriction
virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifoldPtr, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &infoGlobal, btIDebugDraw *debugDrawer)
btAlignedObjectArray< int > m_limitDependencies
void setElem(btMatrixXd &mat, int row, int col, double val)
const btMatrix3x3 & getInvInertiaTensorWorld() const
T & expand(const T &fillValue=T())
btVector3 m_contactNormal1
virtual void createMLCPFast(const btContactSolverInfo &infoGlobal)
btSimdScalar m_appliedImpulse
btConstraintArray m_tmpSolverNonContactConstraintPool
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btVector3 m_contactNormal2