454 for (i = 0; i < 3; i++)
464 for (i = 0; i < 3; i++)
486 int row =
setAngularLimits(info, 0, transA, transB, linVelA, linVelB, angVelA, angVelB);
487 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);
548 int row = row_offset;
551 int cIdx[] = {0, 1, 2};
588 for (
int ii = 0; ii < 3; ii++)
611 row +=
get_limit_motor_info2(&
m_angularLimits[i], transA, transB, linVelA, linVelB, angVelA, angVelB, info, row, axis, 1);
630 for (
int i = 0; i < 3; i++)
642 J1[srow + 0] = ax1[0];
643 J1[srow + 1] = ax1[1];
644 J1[srow + 2] = ax1[2];
646 J2[srow + 0] = -ax1[0];
647 J2[srow + 1] = -ax1[1];
648 J2[srow + 2] = -ax1[2];
657 tmpA = relA.
cross(ax1);
658 tmpB = relB.
cross(ax1);
676 int srow = row * info->
rowskip;
680 btScalar vel = rotational ? angVelA.
dot(ax1) - angVelB.
dot(ax1) : linVelA.
dot(ax1) - linVelB.
dot(ax1);
682 calculateJacobi(limot, transA, transB, info, srow, ax1, rotational, rotAllowed);
697 if (bounceerror < info->m_constraintError[srow]) info->
m_constraintError[srow] = bounceerror;
706 calculateJacobi(limot, transA, transB, info, srow, ax1, rotational, rotAllowed);
713 if (bounceerror < info->m_constraintError[srow]) info->
m_constraintError[srow] = bounceerror;
732 calculateJacobi(limot, transA, transB, info, srow, ax1, rotational, rotAllowed);
743 calculateJacobi(limot, transA, transB, info, srow, ax1, rotational, rotAllowed);
776 calculateJacobi(limot, transA, transB, info, srow, ax1, rotational, rotAllowed);
791 lowLimit = error > 0 && curServoTarget > limot->
m_loLimit ? curServoTarget : limot->
m_loLimit;
792 hiLimit = error < 0 && curServoTarget < limot->
m_hiLimit ? curServoTarget : limot->
m_hiLimit;
800 info->
m_constraintError[srow] = mot_fact * targetvelocity * (rotational ? -1 : 1);
811 calculateJacobi(limot, transA, transB, info, srow, ax1, rotational, rotAllowed);
827 vel = angVelA.
dot(ax1) - angVelB.
dot(ax1);
833 vel = (linVelA + tanVelA).
dot(ax1) - (linVelB + tanVelB).
dot(ax1);
848 m = mA*mB / (mA + mB);
862 btScalar fd = -kd * (vel) * (rotational ? -1 : 1) * dt;
897 info->
cfm[srow] = cfm;
909 if ((axis >= 0) && (axis < 3))
933 else if ((axis >= 3) && (axis < 6))
967 if ((axis >= 0) && (axis < 3))
991 else if ((axis >= 3) && (axis < 6))
1031 xAxis[1], yAxis[1], zAxis[1],
1032 xAxis[2], yAxis[2], zAxis[2]);
1043 btAssert((index >= 0) && (index < 6));
1052 btAssert((index >= 0) && (index < 6));
1061 btAssert((index >= 0) && (index < 6));
1070 btAssert((index >= 0) && (index < 6));
1079 btAssert((index >= 0) && (index < 6));
1123 btAssert((index >= 0) && (index < 6));
1132 btAssert((index >= 0) && (index < 6));
1141 btAssert((index >= 0) && (index < 6));
1156 btAssert((index >= 0) && (index < 6));
1173 for (i = 0; i < 3; i++)
1175 for (i = 0; i < 3; i++)
1181 btAssert((index >= 0) && (index < 6));
1191 btAssert((index >= 0) && (index < 6));
1227 if (loLimit > hiLimit)
1232 else if (loLimit == hiLimit)
#define D6_LIMIT_ERROR_THRESHOLD_FOR_ROTATION
#define BT_6DOF_FLAGS_AXIS_SHIFT2
@ BT_6DOF_FLAGS_ERP_MOTO2
@ BT_6DOF_FLAGS_CFM_MOTO2
@ BT_6DOF_FLAGS_ERP_STOP2
@ BT_6DOF_FLAGS_CFM_STOP2
@ BT_6DOF_FLAGS_USE_INFINITE_ERROR
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
btScalar length(const btQuaternion &q)
Return the length of a quaternion.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btScalar btSqrt(btScalar y)
btScalar btAtan2(btScalar x, btScalar y)
btScalar btAsin(btScalar x)
#define btAssertConstrParams(_par)
btScalar btAdjustAngleToLimits(btScalar angleInRadians, btScalar angleLowerLimitInRadians, btScalar angleUpperLimitInRadians)
@ D6_SPRING_2_CONSTRAINT_TYPE
btVector3 m_calculatedAxis[3]
static bool matrixToEulerYZX(const btMatrix3x3 &mat, btVector3 &xyz)
btRotationalLimitMotor2 m_angularLimits[3]
virtual void getInfo1(btConstraintInfo1 *info)
internal method used by the constraint solver, don't use them directly
void setStiffness(int index, btScalar stiffness, bool limitIfNeeded=true)
virtual btScalar getParam(int num, int axis=-1) const
return the local value of parameter
void calculateLinearInfo()
static bool matrixToEulerYXZ(const btMatrix3x3 &mat, btVector3 &xyz)
void setAxis(const btVector3 &axis1, const btVector3 &axis2)
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)
int setLinearLimits(btConstraintInfo2 *info, int row, const btTransform &transA, const btTransform &transB, const btVector3 &linVelA, const btVector3 &linVelB, const btVector3 &angVelA, const btVector3 &angVelB)
btVector3 m_calculatedAxisAngleDiff
btVector3 m_calculatedLinearDiff
void setDamping(int index, btScalar damping, bool limitIfNeeded=true)
void setBounce(int index, btScalar bounce)
static bool matrixToEulerZXY(const btMatrix3x3 &mat, btVector3 &xyz)
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...
static bool matrixToEulerXYZ(const btMatrix3x3 &mat, btVector3 &xyz)
btTransform m_calculatedTransformA
void enableMotor(int index, bool onOff)
btTranslationalLimitMotor2 m_linearLimits
btTransform m_calculatedTransformB
void calculateJacobi(btRotationalLimitMotor2 *limot, const btTransform &transA, const btTransform &transB, btConstraintInfo2 *info, int srow, btVector3 &ax1, int rotational, int rotAllowed)
void calculateAngleInfo()
virtual void getInfo2(btConstraintInfo2 *info)
internal method used by the constraint solver, don't use them directly
void enableSpring(int index, bool onOff)
RotateOrder m_rotateOrder
void setServoTarget(int index, btScalar target)
void testAngularLimitMotor(int axis_index)
static btScalar btGetMatrixElem(const btMatrix3x3 &mat, int index)
void setMaxMotorForce(int index, btScalar force)
static bool matrixToEulerZYX(const btMatrix3x3 &mat, btVector3 &xyz)
void setFrames(const btTransform &frameA, const btTransform &frameB)
btVector3 getAxis(int axis_index) const
static bool matrixToEulerXZY(const btMatrix3x3 &mat, btVector3 &xyz)
void setTargetVelocity(int index, btScalar velocity)
void setEquilibriumPoint()
void setServo(int index, bool onOff)
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...
virtual void buildJacobian()
internal method used by the constraint solver, don't use them directly
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)
void calculateTransforms()
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
btMatrix3x3 inverse() const
Return the inverse of the matrix.
btVector3 getColumn(int i) const
Get a column of the matrix as a vector.
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)
The btRigidBody is the main class for rigid body objects.
btScalar getInvMass() const
const btTransform & getCenterOfMassTransform() const
const btVector3 & getAngularVelocity() const
const btMatrix3x3 & getInvInertiaTensorWorld() const
const btVector3 & getLinearVelocity() const
bool m_springDampingLimited
btScalar m_targetVelocity
void testLimitValue(btScalar test_value)
btScalar m_currentLimitErrorHi
btScalar m_currentPosition
bool m_springStiffnessLimited
btScalar m_currentLimitError
btScalar m_springStiffness
btScalar m_equilibriumPoint
btVector3 m_targetVelocity
btVector3 m_equilibriumPoint
btVector3 m_currentLinearDiff
bool m_springDampingLimited[3]
btVector3 m_currentLimitError
btVector3 m_springStiffness
void testLimitValue(int limitIndex, btScalar test_value)
btVector3 m_currentLimitErrorHi
btVector3 m_maxMotorForce
bool m_springStiffnessLimited[3]
btVector3 m_springDamping
TypedConstraint is the baseclass for Bullet constraints and vehicles.
btScalar getMotorFactor(btScalar pos, btScalar lowLim, btScalar uppLim, btScalar vel, btScalar timeFact)
internal method used by the constraint solver, don't use them directly
const btRigidBody & getRigidBodyA() const
const btRigidBody & getRigidBodyB() const
btVector3 can be used to represent 3D points and vectors.
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
btScalar dot(const btVector3 &v) const
Return the dot product.
btVector3 normalized() const
Return a normalized version of this vector.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
btScalar * m_J2angularAxis
btScalar * m_J1linearAxis
btScalar * m_J2linearAxis
btScalar * m_J1angularAxis
btScalar * m_constraintError