24#define HINGE_USE_OBSOLETE_SOLVER false
26#define HINGE_USE_FRAME_OFFSET true
37 m_enableAngularMotor(false),
40 m_useReferenceFrameA(useReferenceFrameA),
66 rbAxisA2 = axisInA.
cross(rbAxisA1);
67 rbAxisA1 = rbAxisA2.
cross(axisInA);
83#ifndef _BT_USE_CENTER_LIMIT_
88 m_relaxationFactor = 1.0f;
89 m_limitSoftness = 0.9f;
100 m_angularOnly(false),
101 m_enableAngularMotor(false),
104 m_useReferenceFrameA(useReferenceFrameA),
132#ifndef _BT_USE_CENTER_LIMIT_
137 m_relaxationFactor = 1.0f;
138 m_limitSoftness = 0.9f;
139 m_solveLimit =
false;
150 m_angularOnly(false),
151 m_enableAngularMotor(false),
154 m_useReferenceFrameA(useReferenceFrameA),
161#ifndef _BT_USE_CENTER_LIMIT_
166 m_relaxationFactor = 1.0f;
167 m_limitSoftness = 0.9f;
168 m_solveLimit =
false;
178 m_angularOnly(false),
179 m_enableAngularMotor(false),
182 m_useReferenceFrameA(useReferenceFrameA),
192#ifndef _BT_USE_CENTER_LIMIT_
197 m_relaxationFactor = 1.0f;
198 m_limitSoftness = 0.9f;
199 m_solveLimit =
false;
215 btVector3 relPos = pivotBInW - pivotAInW;
229 for (
int i = 0; i < 3; i++)
310 return accAngle + result;
461 for (i = 0; i < 3; i++)
522#ifdef _BT_USE_CENTER_LIMIT_
527 limit = (limit_err >
btScalar(0.0)) ? 1 : 2;
531 if (limit || powered)
545 if (limit && (lostop == histop))
564 k = info->
fps * currERP;
570 if (lostop == histop)
587#ifdef _BT_USE_CENTER_LIMIT_
590 btScalar bounce = m_relaxationFactor;
595 vel -= angVelB.
dot(ax1);
614 if (newc < info->m_constraintError[srow])
621#ifdef _BT_USE_CENTER_LIMIT_
661#ifdef _BT_USE_CENTER_LIMIT_
666 m_solveLimit =
false;
667 if (m_lowerLimit <= m_upperLimit)
709 if (qHinge.
getZ() < 0)
710 targetAngle = -targetAngle;
717#ifdef _BT_USE_CENTER_LIMIT_
720 if (m_lowerLimit < m_upperLimit)
722 if (targetAngle < m_lowerLimit)
723 targetAngle = m_lowerLimit;
724 else if (targetAngle > m_upperLimit)
725 targetAngle = m_upperLimit;
730 btScalar dAngle = targetAngle - curAngle;
766 btVector3 ax1 = ax1A * factA + ax1B * factB;
771 ax1 = ax1A * factA + ax1B * factB;
795 relA = orthoA + totalDist * factA;
796 relB = orthoB - totalDist * factB;
798 p = orthoB * factA + orthoA * factB;
811 tmpA = relA.
cross(p);
812 tmpB = relB.
cross(p);
815 tmpA = relA.
cross(q);
816 tmpB = relB.
cross(q);
825 tmpA = relA.
cross(ax1);
826 tmpB = relB.
cross(ax1);
853 rhs = k * q.
dot(ofs);
855 rhs = k * ax1.
dot(ofs);
895 k = info->
fps * normalErp;
908#ifdef _BT_USE_CENTER_LIMIT_
913 limit = (limit_err >
btScalar(0.0)) ? 1 : 2;
917 if (limit || powered)
931 if (limit && (lostop == histop))
950 k = info->
fps * currERP;
956 if (lostop == histop)
973#ifdef _BT_USE_CENTER_LIMIT_
976 btScalar bounce = m_relaxationFactor;
981 vel -= angVelB.
dot(ax1);
1000 if (newc < info->m_constraintError[srow])
1007#ifdef _BT_USE_CENTER_LIMIT_
1020 if ((axis == -1) || (axis == 5))
1054 if ((axis == -1) || (axis == 5))
#define HINGE_USE_OBSOLETE_SOLVER
static btScalar btShortestAngularDistance(btScalar accAngle, btScalar curAngle)
static btScalar btNormalizeAnglePositive(btScalar angle)
static btVector3 vHinge(0, 0, btScalar(1))
static btScalar btShortestAngleUpdate(btScalar accAngle, btScalar curAngle)
#define HINGE_USE_FRAME_OFFSET
@ BT_HINGE_FLAGS_CFM_STOP
@ BT_HINGE_FLAGS_CFM_NORM
@ BT_HINGE_FLAGS_ERP_NORM
@ BT_HINGE_FLAGS_ERP_STOP
#define _BT_USE_CENTER_LIMIT_
btQuaternion shortestArcQuat(const btVector3 &v0, const btVector3 &v1)
btVector3 quatRotate(const btQuaternion &rotation, const btVector3 &v)
btScalar btNormalizeAngle(btScalar angleInRadians)
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 btFabs(btScalar x)
btScalar btFmod(btScalar x, btScalar y)
#define btAssertConstrParams(_par)
btScalar btAdjustAngleToLimits(btScalar angleInRadians, btScalar angleLowerLimitInRadians, btScalar angleUpperLimitInRadians)
void btPlaneSpace1(const T &n, T &p, T &q)
btScalar getBiasFactor() const
Returns limit's bias factor.
btScalar getCorrection() const
Returns correction value evaluated when test() was invoked.
void test(const btScalar angle)
Checks conastaint angle against limit.
void fit(btScalar &angle) const
Checks given angle against limit.
btScalar getRelaxationFactor() const
Returns limit's relaxation factor.
void setAccumulatedHingeAngle(btScalar accAngle)
btScalar m_accumulatedAngle
btScalar getAccumulatedHingeAngle()
virtual void getInfo1(btConstraintInfo1 *info)
internal method used by the constraint solver, don't use them directly
const btRigidBody & getRigidBodyB() const
btJacobianEntry m_jacAng[3]
btScalar getHingeAngle()
The getHingeAngle gives the hinge angle in range [-PI,PI].
btScalar m_maxMotorImpulse
void setMotorTarget(const btQuaternion &qAinB, btScalar dt)
btScalar m_accLimitImpulse
void getInfo2NonVirtual(btConstraintInfo2 *info, const btTransform &transA, const btTransform &transB, const btVector3 &angVelA, const btVector3 &angVelB)
virtual void getInfo2(btConstraintInfo2 *info)
internal method used by the constraint solver, don't use them directly
btScalar getUpperLimit() const
void setFrames(const btTransform &frameA, const btTransform &frameB)
btScalar m_accMotorImpulse
btScalar getLowerLimit() const
btHingeConstraint(btRigidBody &rbA, btRigidBody &rbB, const btVector3 &pivotInA, const btVector3 &pivotInB, const btVector3 &axisInA, const btVector3 &axisInB, bool useReferenceFrameA=false)
bool m_useSolveConstraintObsolete
bool m_useOffsetForConstraintFrame
void updateRHS(btScalar timeStep)
virtual btScalar getParam(int num, int axis=-1) const
return the local value of parameter
virtual void buildJacobian()
internal method used by the constraint solver, don't use them directly
bool m_useReferenceFrameA
virtual void getInfo1(btConstraintInfo1 *info)
internal method used by the constraint solver, don't use them directly
btScalar m_motorTargetVelocity
void getInfo2Internal(btConstraintInfo2 *info, const btTransform &transA, const btTransform &transB, const btVector3 &angVelA, const btVector3 &angVelB)
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...
void getInfo2InternalUsingFrameOffset(btConstraintInfo2 *info, const btTransform &transA, const btTransform &transB, const btVector3 &angVelA, const btVector3 &angVelB)
void testLimit(const btTransform &transA, const btTransform &transB)
const btRigidBody & getRigidBodyA() const
bool getEnableAngularMotor()
void getInfo1NonVirtual(btConstraintInfo1 *info)
Jacobian entry is an abstraction that allows to describe constraints it can be used in combination wi...
btMatrix3x3 transpose() const
Return the transpose 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)
const btScalar & getZ() const
Return the z value.
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
btScalar getAngle() const
Return the angle [0, 2Pi] of rotation represented by this quaternion.
btQuaternion inverse() const
Return the inverse of this quaternion.
btQuaternion & normalize()
Normalize the quaternion Such that x^2 + y^2 + z^2 +w^2 = 1.
The btRigidBody is the main class for rigid body objects.
btScalar computeAngularImpulseDenominator(const btVector3 &axis) const
btScalar getInvMass() const
const btVector3 & getInvInertiaDiagLocal() const
const btTransform & getCenterOfMassTransform() const
const btVector3 & getAngularVelocity() const
const btVector3 & getCenterOfMassPosition() const
TypedConstraint is the baseclass for Bullet constraints and vehicles.
btScalar m_appliedImpulse
btScalar getMotorFactor(btScalar pos, btScalar lowLim, btScalar uppLim, btScalar vel, btScalar timeFact)
internal method used by the constraint solver, don't use them directly
btVector3 can be used to represent 3D points and vectors.
const btScalar & getZ() const
Return the z value.
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.
void getSkewSymmetricMatrix(btVector3 *v0, btVector3 *v1, btVector3 *v2) const
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
btVector3 normalized() const
Return a normalized version of this vector.
btScalar length2() const
Return the length of the vector squared.
const btScalar & getY() const
Return the y value.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
const btScalar & getX() const
Return the x value.
btScalar * m_J2angularAxis
btScalar * m_J1linearAxis
btScalar * m_J2linearAxis
btScalar * m_J1angularAxis
btScalar * m_constraintError