|
Bullet Collision Detection & Physics Library
|
Go to the documentation of this file.
51 , m_frameInA(frameInA)
52 , m_frameInB(frameInB)
53 , m_rotateOrder(rotOrder)
62 , m_frameInB(frameInB)
63 , m_rotateOrder(rotOrder)
456 for(i = 0; i < 3; i++)
485 int row =
setAngularLimits(info, 0,transA,transB,linVelA,linVelB,angVelA,angVelB);
486 setLinearLimits(info, row, transA,transB,linVelA,linVelB,angVelA,angVelB);
494 for (
int i=0;i<3 ;i++ )
524 int indx1 = (i + 1) % 3;
525 int indx2 = (i + 2) % 3;
527 #define D6_LIMIT_ERROR_THRESHOLD_FOR_ROTATION 1.0e-3
536 if( indx1Violated && indx2Violated )
540 row +=
get_limit_motor_info2(&limot, transA,transB,linVelA,linVelB,angVelA,angVelB, info, row, axis, 0, rotAllowed);
551 int row = row_offset;
554 int cIdx[] = {0, 1, 2};
557 case RO_XYZ : cIdx[0] = 0; cIdx[1] = 1; cIdx[2] = 2;
break;
558 case RO_XZY : cIdx[0] = 0; cIdx[1] = 2; cIdx[2] = 1;
break;
559 case RO_YXZ : cIdx[0] = 1; cIdx[1] = 0; cIdx[2] = 2;
break;
560 case RO_YZX : cIdx[0] = 1; cIdx[1] = 2; cIdx[2] = 0;
break;
561 case RO_ZXY : cIdx[0] = 2; cIdx[1] = 0; cIdx[2] = 1;
break;
562 case RO_ZYX : cIdx[0] = 2; cIdx[1] = 1; cIdx[2] = 0;
break;
566 for (
int ii = 0; ii < 3 ; ii++ )
589 row +=
get_limit_motor_info2(&
m_angularLimits[i],transA,transB,linVelA,linVelB,angVelA,angVelB, info,row,axis,1);
610 for(
int i = 0; i < 3; i++)
626 J2[srow+0] = -ax1[0];
627 J2[srow+1] = -ax1[1];
628 J2[srow+2] = -ax1[2];
637 tmpA = relA.
cross(ax1);
638 tmpB = relB.
cross(ax1);
657 int srow = row * info->
rowskip;
661 btScalar vel = rotational ? angVelA.
dot(ax1) - angVelB.
dot(ax1) : linVelA.
dot(ax1) - linVelB.
dot(ax1);
663 calculateJacobi(limot,transA,transB,info,srow,ax1,rotational,rotAllowed);
673 if (bounceerror < info->m_constraintError[srow]) info->
m_constraintError[srow] = bounceerror;
682 calculateJacobi(limot,transA,transB,info,srow,ax1,rotational,rotAllowed);
687 if (bounceerror < info->m_constraintError[srow]) info->
m_constraintError[srow] = bounceerror;
703 calculateJacobi(limot,transA,transB,info,srow,ax1,rotational,rotAllowed);
714 calculateJacobi(limot,transA,transB,info,srow,ax1,rotational,rotAllowed);
747 calculateJacobi(limot,transA,transB,info,srow,ax1,rotational,rotAllowed);
762 lowLimit = error > 0 && curServoTarget>limot->
m_loLimit ? curServoTarget : limot->
m_loLimit;
763 hiLimit = error < 0 && curServoTarget<limot->
m_hiLimit ? curServoTarget : limot->
m_hiLimit;
771 info->
m_constraintError[srow] = mot_fact * targetvelocity * (rotational ? -1 : 1);
782 calculateJacobi(limot,transA,transB,info,srow,ax1,rotational,rotAllowed);
795 btScalar vel = rotational ? angVelA.
dot(ax1) - angVelB.
dot(ax1) : linVelA.
dot(ax1) - linVelB.
dot(ax1);
801 btScalar angularfreq = sqrt(ks / m);
815 btScalar fd = -kd * (vel) * (rotational ? -1 : 1) * dt;
833 info->
cfm[srow] = cfm;
846 if((axis >= 0) && (axis < 3))
870 else if((axis >=3) && (axis < 6))
904 if((axis >= 0) && (axis < 3))
928 else if((axis >=3) && (axis < 6))
970 xAxis[1], yAxis[1], zAxis[1],
971 xAxis[2], yAxis[2], zAxis[2]);
982 btAssert((index >= 0) && (index < 6));
991 btAssert((index >= 0) && (index < 6));
1000 btAssert((index >= 0) && (index < 6));
1009 btAssert((index >= 0) && (index < 6));
1020 btAssert((index >= 0) && (index < 6));
1063 btAssert((index >= 0) && (index < 6));
1072 btAssert((index >= 0) && (index < 6));
1081 btAssert((index >= 0) && (index < 6));
1093 btAssert((index >= 0) && (index < 6));
1107 for( i = 0; i < 3; i++)
1109 for(i = 0; i < 3; i++)
1115 btAssert((index >= 0) && (index < 6));
1125 btAssert((index >= 0) && (index < 6));
1158 if(loLimit > hiLimit) {
1162 else if(loLimit == hiLimit) {
bool m_springStiffnessLimited[3]
TypedConstraint is the baseclass for Bullet constraints and vehicles.
void calculateAngleInfo()
The btRigidBody is the main class for rigid body objects.
#define btAssertConstrParams(_par)
virtual void setParam(int num, btScalar value, int axis=-1)
override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0...
btVector3 m_currentLimitError
btVector3 m_targetVelocity
void setBounce(int index, btScalar bounce)
btScalar m_equilibriumPoint
const btVector3 & getAngularVelocity() const
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
int setLinearLimits(btConstraintInfo2 *info, int row, const btTransform &transA, const btTransform &transB, const btVector3 &linVelA, const btVector3 &linVelB, const btVector3 &angVelA, const btVector3 &angVelB)
const btRigidBody & getRigidBodyA() const
btMatrix3x3 inverse() const
Return the inverse of the matrix.
void setMaxMotorForce(int index, btScalar force)
btVector3 m_currentLimitErrorHi
btVector3 m_calculatedAxis[3]
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
btScalar m_currentPosition
static bool matrixToEulerYXZ(const btMatrix3x3 &mat, btVector3 &xyz)
btScalar m_currentLimitErrorHi
btScalar * m_J2angularAxis
btScalar dot(const btVector3 &v) const
Return the dot product.
void setStiffness(int index, btScalar stiffness, bool limitIfNeeded=true)
btVector3 getAxis(int axis_index) const
btScalar * m_J2linearAxis
void testLimitValue(int limitIndex, btScalar test_value)
const btTransform & getCenterOfMassTransform() const
btScalar m_targetVelocity
btVector3 m_calculatedLinearDiff
void testAngularLimitMotor(int axis_index)
#define BT_6DOF_FLAGS_AXIS_SHIFT2
const btRigidBody & getRigidBodyB() const
void calculateLinearInfo()
virtual void getInfo1(btConstraintInfo1 *info)
internal method used by the constraint solver, don't use them directly
btScalar m_currentLimitError
static bool matrixToEulerZYX(const btMatrix3x3 &mat, btVector3 &xyz)
btTranslationalLimitMotor2 m_linearLimits
void enableSpring(int index, bool onOff)
void setEquilibriumPoint()
int setAngularLimits(btConstraintInfo2 *info, int row_offset, const btTransform &transA, const btTransform &transB, const btVector3 &linVelA, const btVector3 &linVelB, const btVector3 &angVelA, const btVector3 &angVelB)
#define D6_LIMIT_ERROR_THRESHOLD_FOR_ROTATION
btVector3 m_currentLinearDiff
bool m_springStiffnessLimited
btTransform m_calculatedTransformB
@ BT_6DOF_FLAGS_ERP_STOP2
bool m_springDampingLimited
@ BT_6DOF_FLAGS_ERP_MOTO2
virtual void buildJacobian()
internal method used by the constraint solver, don't use them directly
btVector3 m_springDamping
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
btGeneric6DofSpring2Constraint(btRigidBody &rbA, btRigidBody &rbB, const btTransform &frameInA, const btTransform &frameInB, RotateOrder rotOrder=RO_XYZ)
2009 March: btGeneric6DofConstraint refactored by Roman Ponomarev Added support for generic constrain...
btScalar * m_constraintError
btScalar getInvMass() const
btVector3 getColumn(int i) const
Get a column of the matrix as a vector.
static bool matrixToEulerXYZ(const btMatrix3x3 &mat, btVector3 &xyz)
btVector3 can be used to represent 3D points and vectors.
static bool matrixToEulerZXY(const btMatrix3x3 &mat, btVector3 &xyz)
RotateOrder m_rotateOrder
void calculateJacobi(btRotationalLimitMotor2 *limot, const btTransform &transA, const btTransform &transB, btConstraintInfo2 *info, int srow, btVector3 &ax1, int rotational, int rotAllowed)
const btVector3 & getLinearVelocity() const
@ D6_SPRING_2_CONSTRAINT_TYPE
void setServo(int index, bool onOff)
@ BT_6DOF_FLAGS_CFM_STOP2
btVector3 m_maxMotorForce
int get_limit_motor_info2(btRotationalLimitMotor2 *limot, const btTransform &transA, const btTransform &transB, const btVector3 &linVelA, const btVector3 &linVelB, const btVector3 &angVelA, const btVector3 &angVelB, btConstraintInfo2 *info, int row, btVector3 &ax1, int rotational, int rotAllowed=false)
virtual btScalar getParam(int num, int axis=-1) const
return the local value of parameter
void testLimitValue(btScalar test_value)
void setValue(const btScalar &xx, const btScalar &xy, const btScalar &xz, const btScalar &yx, const btScalar &yy, const btScalar &yz, const btScalar &zx, const btScalar &zy, const btScalar &zz)
Set the values of the matrix explicitly (row major)
void setAxis(const btVector3 &axis1, const btVector3 &axis2)
bool m_springDampingLimited[3]
static bool matrixToEulerXZY(const btMatrix3x3 &mat, btVector3 &xyz)
btScalar btAdjustAngleToLimits(btScalar angleInRadians, btScalar angleLowerLimitInRadians, btScalar angleUpperLimitInRadians)
static btScalar btGetMatrixElem(const btMatrix3x3 &mat, int index)
void setFrames(const btTransform &frameA, const btTransform &frameB)
void calculateTransforms()
void setDamping(int index, btScalar damping, bool limitIfNeeded=true)
virtual void getInfo2(btConstraintInfo2 *info)
internal method used by the constraint solver, don't use them directly
btVector3 m_equilibriumPoint
btScalar btAtan2(btScalar x, btScalar y)
btVector3 m_springStiffness
void setServoTarget(int index, btScalar target)
btScalar getMotorFactor(btScalar pos, btScalar lowLim, btScalar uppLim, btScalar vel, btScalar timeFact)
internal method used by the constraint solver, don't use them directly
btScalar * m_J1angularAxis
btRotationalLimitMotor2 m_angularLimits[3]
@ BT_6DOF_FLAGS_CFM_MOTO2
void enableMotor(int index, bool onOff)
static bool matrixToEulerYZX(const btMatrix3x3 &mat, btVector3 &xyz)
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
btVector3 normalized() const
Return a normalized version of this vector.
btScalar * m_J1linearAxis
btScalar m_springStiffness
btScalar btAsin(btScalar x)
btVector3 m_calculatedAxisAngleDiff
btTransform m_calculatedTransformA
void setTargetVelocity(int index, btScalar velocity)