27 #define HINGE_USE_OBSOLETE_SOLVER false
29 #define HINGE_USE_FRAME_OFFSET true
44 m_enableAngularMotor(false),
47 m_useReferenceFrameA(useReferenceFrameA),
64 rbAxisA2 = axisInA.
cross(rbAxisA1);
65 rbAxisA1 = rbAxisA2.
cross(axisInA);
81 #ifndef _BT_USE_CENTER_LIMIT_
86 m_relaxationFactor = 1.0f;
87 m_limitSoftness = 0.9f;
100 m_angularOnly(false), m_enableAngularMotor(false),
103 m_useReferenceFrameA(useReferenceFrameA),
129 #ifndef _BT_USE_CENTER_LIMIT_
134 m_relaxationFactor = 1.0f;
135 m_limitSoftness = 0.9f;
136 m_solveLimit =
false;
149 m_angularOnly(false),
150 m_enableAngularMotor(false),
153 m_useReferenceFrameA(useReferenceFrameA),
156 #ifndef _BT_USE_CENTER_LIMIT_
161 m_relaxationFactor = 1.0f;
162 m_limitSoftness = 0.9f;
163 m_solveLimit =
false;
175 m_angularOnly(false),
176 m_enableAngularMotor(false),
179 m_useReferenceFrameA(useReferenceFrameA),
185 #ifndef _BT_USE_CENTER_LIMIT_
190 m_relaxationFactor = 1.0f;
191 m_limitSoftness = 0.9f;
192 m_solveLimit =
false;
210 btVector3 relPos = pivotBInW - pivotAInW;
224 for (
int i=0;i<3;i++)
419 for(i = 0; i < 3; i++)
480 #ifdef _BT_USE_CENTER_LIMIT_
485 limit = (limit_err >
btScalar(0.0)) ? 1 : 2;
508 if(limit && (lostop == histop))
527 k = info->
fps * currERP;
550 #ifdef _BT_USE_CENTER_LIMIT_
553 btScalar bounce = m_relaxationFactor;
558 vel -= angVelB.
dot(ax1);
577 if(newc < info->m_constraintError[srow])
584 #ifdef _BT_USE_CENTER_LIMIT_
630 #ifdef _BT_USE_CENTER_LIMIT_
635 m_solveLimit =
false;
636 if (m_lowerLimit <= m_upperLimit)
678 if (qHinge.
getZ() < 0)
679 targetAngle = -targetAngle;
686 #ifdef _BT_USE_CENTER_LIMIT_
689 if (m_lowerLimit < m_upperLimit)
691 if (targetAngle < m_lowerLimit)
692 targetAngle = m_lowerLimit;
693 else if (targetAngle > m_upperLimit)
694 targetAngle = m_upperLimit;
699 btScalar dAngle = targetAngle - curAngle;
737 btVector3 ax1 = ax1A * factA + ax1B * factB;
760 relA = orthoA + totalDist * factA;
761 relB = orthoB - totalDist * factB;
763 p = orthoB * factA + orthoA * factB;
776 tmpA = relA.
cross(p);
777 tmpB = relB.
cross(p);
780 tmpA = relA.
cross(q);
781 tmpB = relB.
cross(q);
790 tmpA = relA.
cross(ax1);
791 tmpB = relB.
cross(ax1);
817 rhs = k * q.
dot(ofs);
819 rhs = k * ax1.
dot(ofs);
859 k = info->
fps * info->
erp;
871 #ifdef _BT_USE_CENTER_LIMIT_
876 limit = (limit_err >
btScalar(0.0)) ? 1 : 2;
899 if(limit && (lostop == histop))
918 k = info->
fps * currERP;
941 #ifdef _BT_USE_CENTER_LIMIT_
944 btScalar bounce = m_relaxationFactor;
949 vel -= angVelB.
dot(ax1);
968 if(newc < info->m_constraintError[srow])
975 #ifdef _BT_USE_CENTER_LIMIT_
989 if((axis == -1) || (axis == 5))
1019 if((axis == -1) || (axis == 5))
btScalar * m_constraintError
btScalar getInvMass() const
#define HINGE_USE_OBSOLETE_SOLVER
void getInfo2Internal(btConstraintInfo2 *info, const btTransform &transA, const btTransform &transB, const btVector3 &angVelA, const btVector3 &angVelB)
btScalar getAngle() const
Return the angle of rotation represented by this quaternion.
btScalar * m_J2angularAxis
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...
btScalar computeAngularImpulseDenominator(const btVector3 &axis) const
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Jacobian entry is an abstraction that allows to describe constraints it can be used in combination wi...
virtual void getInfo1(btConstraintInfo1 *info)
internal method used by the constraint solver, don't use them directly
bool m_useSolveConstraintObsolete
btScalar m_accMotorImpulse
void btPlaneSpace1(const T &n, T &p, T &q)
btScalar btSqrt(btScalar y)
btScalar * m_J1angularAxis
btVector3 getColumn(int i) const
Get a column of the matrix as a vector.
const btRigidBody & getRigidBodyA() const
btScalar m_motorTargetVelocity
btScalar dot(const btVector3 &v) const
Return the dot product.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
btVector3 quatRotate(const btQuaternion &rotation, const btVector3 &v)
const btScalar & getZ() const
Return the z value.
static btVector3 vHinge(0, 0, btScalar(1))
btScalar * m_J1linearAxis
void getInfo2NonVirtual(btConstraintInfo2 *info, const btTransform &transA, const btTransform &transB, const btVector3 &angVelA, const btVector3 &angVelB)
btScalar m_accLimitImpulse
btScalar getUpperLimit() const
btQuaternion shortestArcQuat(const btVector3 &v0, const btVector3 &v1)
#define _BT_USE_CENTER_LIMIT_
float projection(const Point3 &pnt, const Vector3 &unitVec)
const btTransform & getCenterOfMassTransform() const
btQuaternion & normalize()
Normalize the quaternion Such that x^2 + y^2 + z^2 +w^2 = 1.
void updateRHS(btScalar timeStep)
void getInfo2InternalUsingFrameOffset(btConstraintInfo2 *info, const btTransform &transA, const btTransform &transB, const btVector3 &angVelA, const btVector3 &angVelB)
btScalar btAtan2(btScalar x, btScalar y)
btScalar getBiasFactor() const
Returns limit's bias factor.
const btVector3 & getAngularVelocity() const
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
const btScalar & getY() const
Return the y value.
virtual btScalar getParam(int num, int axis=-1) const
return the local value of parameter
const btScalar & getX() const
Return the x value.
#define HINGE_USE_FRAME_OFFSET
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)
btScalar m_maxMotorImpulse
btScalar getLowerLimit() const
void getInfo1NonVirtual(btConstraintInfo1 *info)
const btVector3 & getCenterOfMassPosition() const
btQuaternion inverse() const
Return the inverse of this quaternion.
The btRigidBody is the main class for rigid body objects.
virtual void buildJacobian()
internal method used by the constraint solver, don't use them directly
btScalar btAdjustAngleToLimits(btScalar angleInRadians, btScalar angleLowerLimitInRadians, btScalar angleUpperLimitInRadians)
btVector3 can be used to represent 3D points and vectors.
btScalar length2() const
Return the length of the vector squared.
bool m_useOffsetForConstraintFrame
bool m_useReferenceFrameA
btJacobianEntry m_jacAng[3]
bool getEnableAngularMotor()
btVector3 normalized() const
Return a normalized version of this vector.
btScalar * m_J2linearAxis
btScalar getRelaxationFactor() const
Returns limit's relaxation factor.
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
btMatrix3x3 transpose() const
Return the transpose of the matrix.
virtual void getInfo2(btConstraintInfo2 *info)
internal method used by the constraint solver, don't use them directly
void fit(btScalar &angle) const
Checks given angle against limit.
btScalar m_appliedImpulse
const btVector3 & getInvInertiaDiagLocal() const
btScalar getCorrection() const
Returns correction value evaluated when test() was invoked.
void setFrames(const btTransform &frameA, const btTransform &frameB)
void setMotorTarget(const btQuaternion &qAinB, btScalar dt)
void test(const btScalar angle)
Checks conastaint angle against limit.
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
const btRigidBody & getRigidBodyB() const
#define btAssertConstrParams(_par)
void testLimit(const btTransform &transA, const btTransform &transB)
btHingeConstraint(btRigidBody &rbA, btRigidBody &rbB, const btVector3 &pivotInA, const btVector3 &pivotInB, const btVector3 &axisInA, const btVector3 &axisInB, bool useReferenceFrameA=false)
const btScalar & getZ() const
Return the z value.
void getSkewSymmetricMatrix(btVector3 *v0, btVector3 *v1, btVector3 *v2) const
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...