2017-08-01 12:30:58 +00:00
/*
Bullet Continuous Collision Detection and Physics Library
Copyright ( c ) 2013 Erwin Coumans http : //bulletphysics.org
This software is provided ' as - is ' , without any express or implied warranty .
In no event will the authors be held liable for any damages arising from the use of this software .
Permission is granted to anyone to use this software for any purpose ,
including commercial applications , and to alter it and redistribute it freely ,
subject to the following restrictions :
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 .
2. Altered source versions must be plainly marked as such , and must not be misrepresented as being the original software .
3. This notice may not be removed or altered from any source distribution .
*/
# ifndef BT_MULTIBODY_CONSTRAINT_SOLVER_H
# define BT_MULTIBODY_CONSTRAINT_SOLVER_H
# include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
# include "btMultiBodySolverConstraint.h"
# define DIRECTLY_UPDATE_VELOCITY_DURING_SOLVER_ITERATIONS
class btMultiBody ;
# include "btMultiBodyConstraint.h"
2019-01-03 13:26:51 +00:00
ATTRIBUTE_ALIGNED16 ( class )
btMultiBodyConstraintSolver : public btSequentialImpulseConstraintSolver
2017-08-01 12:30:58 +00:00
{
protected :
2019-01-03 13:26:51 +00:00
btMultiBodyConstraintArray m_multiBodyNonContactConstraints ;
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
btMultiBodyConstraintArray m_multiBodyNormalContactConstraints ;
btMultiBodyConstraintArray m_multiBodyFrictionContactConstraints ;
btMultiBodyConstraintArray m_multiBodyTorsionalFrictionContactConstraints ;
2019-06-11 11:18:05 +00:00
btMultiBodyConstraintArray m_multiBodySpinningFrictionContactConstraints ;
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
btMultiBodyJacobianData m_data ;
2017-08-01 12:30:58 +00:00
//temp storage for multi body constraints for a specific island/group called by 'solveGroup'
2019-01-03 13:26:51 +00:00
btMultiBodyConstraint * * m_tmpMultiBodyConstraints ;
int m_tmpNumMultiBodyConstraints ;
2017-08-01 12:30:58 +00:00
btScalar resolveSingleConstraintRowGeneric ( const btMultiBodySolverConstraint & c ) ;
2019-01-03 13:26:51 +00:00
2018-09-07 14:11:04 +00:00
//solve 2 friction directions and clamp against the implicit friction cone
btScalar resolveConeFrictionConstraintRows ( const btMultiBodySolverConstraint & cA1 , const btMultiBodySolverConstraint & cB ) ;
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
void convertContacts ( btPersistentManifold * * manifoldPtr , int numManifolds , const btContactSolverInfo & infoGlobal ) ;
2017-08-01 12:30:58 +00:00
2020-01-08 17:05:43 +00:00
btMultiBodySolverConstraint & addMultiBodyFrictionConstraint ( const btVector3 & normalAxis , const btScalar & appliedImpulse , btPersistentManifold * manifold , int frictionIndex , btManifoldPoint & cp , btCollisionObject * colObj0 , btCollisionObject * colObj1 , btScalar relaxation , const btContactSolverInfo & infoGlobal , btScalar desiredVelocity = 0 , btScalar cfmSlip = 0 ) ;
2019-01-03 13:26:51 +00:00
btMultiBodySolverConstraint & addMultiBodyTorsionalFrictionConstraint ( const btVector3 & normalAxis , btPersistentManifold * manifold , int frictionIndex , btManifoldPoint & cp ,
btScalar combinedTorsionalFriction ,
btCollisionObject * colObj0 , btCollisionObject * colObj1 , btScalar relaxation , const btContactSolverInfo & infoGlobal , btScalar desiredVelocity = 0 , btScalar cfmSlip = 0 ) ;
2017-08-01 12:30:58 +00:00
2019-06-11 11:18:05 +00:00
btMultiBodySolverConstraint & addMultiBodySpinningFrictionConstraint ( const btVector3 & normalAxis , btPersistentManifold * manifold , int frictionIndex , btManifoldPoint & cp ,
btScalar combinedTorsionalFriction ,
btCollisionObject * colObj0 , btCollisionObject * colObj1 , btScalar relaxation , const btContactSolverInfo & infoGlobal , btScalar desiredVelocity = 0 , btScalar cfmSlip = 0 ) ;
2019-01-03 13:26:51 +00:00
void setupMultiBodyJointLimitConstraint ( btMultiBodySolverConstraint & constraintRow ,
btScalar * jacA , btScalar * jacB ,
btScalar penetration , btScalar combinedFrictionCoeff , btScalar combinedRestitutionCoeff ,
const btContactSolverInfo & infoGlobal ) ;
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
void setupMultiBodyContactConstraint ( btMultiBodySolverConstraint & solverConstraint ,
const btVector3 & contactNormal ,
2020-01-08 17:05:43 +00:00
const btScalar & appliedImpulse ,
btManifoldPoint & cp ,
const btContactSolverInfo & infoGlobal ,
2019-01-03 13:26:51 +00:00
btScalar & relaxation ,
bool isFriction , btScalar desiredVelocity = 0 , btScalar cfmSlip = 0 ) ;
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
//either rolling or spinning friction
void setupMultiBodyTorsionalFrictionConstraint ( btMultiBodySolverConstraint & solverConstraint ,
const btVector3 & contactNormal ,
btManifoldPoint & cp ,
btScalar combinedTorsionalFriction ,
const btContactSolverInfo & infoGlobal ,
btScalar & relaxation ,
bool isFriction , btScalar desiredVelocity = 0 , btScalar cfmSlip = 0 ) ;
void convertMultiBodyContact ( btPersistentManifold * manifold , const btContactSolverInfo & infoGlobal ) ;
virtual btScalar solveGroupCacheFriendlySetup ( btCollisionObject * * bodies , int numBodies , btPersistentManifold * * manifoldPtr , int n umManifolds , btTypedConstraint * * constraints , int numConstraints , const btContactSolverInfo & infoGlobal , btIDebugDraw * debugDrawer ) ;
// virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
virtual btScalar solveSingleIteration ( int iteration , btCollisionObject * * bodies , int numBodies , btPersistentManifold * * manifoldPtr , int numManifolds , btTypedConstraint * * constraints , int numConstraints , const btContactSolverInfo & infoGlobal , btIDebugDraw * debugDrawer ) ;
void applyDeltaVee ( btScalar * deltaV , btScalar impulse , int velocityIndex , int ndof ) ;
void writeBackSolverBodyToMultiBody ( btMultiBodySolverConstraint & constraint , btScalar deltaTime ) ;
public :
BT_DECLARE_ALIGNED_ALLOCATOR ( ) ;
///this method should not be called, it was just used during porting/integration of Featherstone btMultiBody, providing backwards compatibility but no support for btMultiBodyConstraint (only contact constraints)
virtual btScalar solveGroup ( btCollisionObject * * bodies , int numBodies , btPersistentManifold * * manifold , int numManifolds , btTypedConstraint * * constraints , int numConstraints , const btContactSolverInfo & info , btIDebugDraw * debugDrawer , btDispatcher * dispatcher ) ;
virtual btScalar solveGroupCacheFriendlyFinish ( btCollisionObject * * bodies , int numBodies , const btContactSolverInfo & infoGlobal ) ;
virtual void solveMultiBodyGroup ( btCollisionObject * * bodies , int numBodies , btPersistentManifold * * manifold , int numManifolds , btTypedConstraint * * constraints , int numConstraints , btMultiBodyConstraint * * multiBodyConstraints , int numMultiBodyConstraints , const btContactSolverInfo & info , btIDebugDraw * debugDrawer , btDispatcher * dispatcher ) ;
} ;
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
# endif //BT_MULTIBODY_CONSTRAINT_SOLVER_H