Bullet Collision Detection & Physics Library
|
Go to the documentation of this file.
26 #define CONETWIST_USE_OBSOLETE_SOLVER false
27 #define CONETWIST_DEF_FIX_THRESH btScalar(.05f)
111 calcAngleInfo2(transA, transB, invInertiaWorldA, invInertiaWorldB);
140 for (j = 0; j < 3; j++)
151 int srow = row * info->
rowskip;
163 int srow1 = srow + info->
rowskip;
167 J1[srow1 + 0] = q[0];
168 J1[srow1 + 1] = q[1];
169 J1[srow1 + 2] = q[2];
170 J2[srow + 0] = -p[0];
171 J2[srow + 1] = -p[1];
172 J2[srow + 2] = -p[2];
173 J2[srow1 + 0] = -q[0];
174 J2[srow1 + 1] = -q[1];
175 J2[srow1 + 2] = -q[2];
188 J1[srow + 0] = ax1[0];
189 J1[srow + 1] = ax1[1];
190 J1[srow + 2] = ax1[2];
191 J2[srow + 0] = -ax1[0];
192 J2[srow + 1] = -ax1[1];
193 J2[srow + 2] = -ax1[2];
212 J1[srow + 0] = ax1[0];
213 J1[srow + 1] = ax1[1];
214 J1[srow + 2] = ax1[2];
215 J2[srow + 0] = -ax1[0];
216 J2[srow + 1] = -ax1[1];
217 J2[srow + 2] = -ax1[2];
259 btVector3 relPos = pivotBInW - pivotAInW;
273 for (
int i = 0; i < 3; i++)
314 for (
int i = 0; i < 3; i++)
320 rel_vel = normal.
dot(vel);
322 btScalar depth = -(pivotAInW - pivotBInW).
dot(normal);
323 btScalar impulse = depth * tau / timeStep * jacDiagABInv - rel_vel * jacDiagABInv;
347 trACur, zerovec, omegaA, timeStep, trAPred);
351 trBCur, zerovec, omegaB, timeStep, trBPred);
371 btScalar kAxisAInv = 0, kAxisBInv = 0;
385 btVector3 avgAxis = kAxisAInv * axisA + kAxisBInv * axisB;
387 static bool bDoTorque =
true;
393 btScalar kInvCombined = kAxisAInv + kAxisBInv;
395 btVector3 impulse = (kAxisAInv * dOmegaA - kAxisBInv * dOmegaB) /
396 (kInvCombined * kInvCombined);
402 fMaxImpulse = fMaxImpulse / kAxisAInv;
406 if (newUnclampedMag > fMaxImpulse)
409 newUnclampedAccImpulse *= fMaxImpulse;
416 btVector3 impulseAxis = impulse / impulseMag;
438 btVector3 impulseAxis = impulse / impulseMag;
472 btVector3 impulseNoTwistCouple = impulse - impulseTwistCouple;
473 impulse = impulseNoTwistCouple;
476 impulseMag = impulse.
length();
477 btVector3 noTwistSwingAxis = impulse / impulseMag;
522 btVector3 b1Axis1(0, 0, 0), b1Axis2(0, 0, 0), b1Axis3(0, 0, 0);
523 btVector3 b2Axis1(0, 0, 0), b2Axis2(0, 0, 0);
538 swx = b2Axis1.
dot(b1Axis1);
539 swy = b2Axis1.dot(b1Axis2);
541 fact = (swy * swy + swx * swx) * thresh * thresh;
542 fact = fact / (fact +
btScalar(1.0));
549 swx = b2Axis1.
dot(b1Axis1);
550 swy = b2Axis1.dot(b1Axis3);
552 fact = (swy * swy + swx * swx) * thresh * thresh;
553 fact = fact / (fact +
btScalar(1.0));
559 btScalar EllipseAngle =
btFabs(swing1 * swing1) * RMaxAngle1Sq +
btFabs(swing2 * swing2) * RMaxAngle2Sq;
561 if (EllipseAngle > 1.0f)
566 m_swingAxis = b2Axis1.
cross(b1Axis2 * b2Axis1.dot(b1Axis2) + b1Axis3 * b2Axis1.
dot(b1Axis3));
568 btScalar swingAxisSign = (b2Axis1.dot(b1Axis1) >= 0.0f) ? 1.0f : -1.0f;
653 btScalar swingAngle, swingLimit = 0;
756 target[0] = x * ivA[0] + y * jvA[0] + z * kvA[0];
757 target[1] = x * ivA[1] + y * jvA[1] + z * kvA[1];
758 target[2] = x * ivA[2] + y * jvA[2] + z * kvA[2];
815 vSwingAxis =
btVector3(qCone.
x(), qCone.
y(), qCone.
z());
842 btScalar surfaceSlope2 = (yEllipse * yEllipse) / (xEllipse * xEllipse);
845 btScalar swingLimit2 = (1 + surfaceSlope2) / norm;
846 swingLimit = std::sqrt(swingLimit2);
862 else if (swingAngle < 0)
887 btScalar surfaceSlope2 = (yEllipse * yEllipse) / (xEllipse * xEllipse);
890 btScalar swingLimit2 = (1 + surfaceSlope2) / norm;
891 swingLimit = std::sqrt(swingLimit2);
896 btVector3 vSwingAxis(0, xEllipse, -yEllipse);
898 btVector3 vPointInConstraintSpace(fLength, 0, 0);
899 return quatRotate(qSwing, vPointInConstraintSpace);
913 qMinTwist = -(qTwist);
924 vTwistAxis =
btVector3(qMinTwist.
x(), qMinTwist.
y(), qMinTwist.
z());
998 if (swingAngle > swingLimit * softness)
999 swingAngle = swingLimit * softness;
1000 else if (swingAngle < -swingLimit * softness)
1001 swingAngle = -swingLimit * softness;
1036 if ((axis >= 0) && (axis < 3))
1048 if ((axis >= 0) && (axis < 3))
1073 if ((axis >= 0) && (axis < 3))
1078 else if ((axis >= 3) && (axis < 6))
1089 if ((axis >= 0) && (axis < 3))
1094 else if ((axis >= 3) && (axis < 6))
virtual void solveConstraintObsolete(btSolverBody &bodyA, btSolverBody &bodyB, btScalar timeStep)
internal method used by the constraint solver, don't use them directly
The btSolverBody is an internal datastructure for the constraint solver. Only necessary data is packe...
TypedConstraint is the baseclass for Bullet constraints and vehicles.
bool m_bNormalizedMotorStrength
The btRigidBody is the main class for rigid body objects.
const btRigidBody & getRigidBodyB() const
#define btAssertConstrParams(_par)
const btScalar & y() const
Return the y value.
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
void btPlaneSpace1(const T &n, T &p, T &q)
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
btScalar length() const
Return the length of the vector.
virtual btScalar getParam(int num, int axis=-1) const
return the local value of parameter
btScalar getAngle() const
Return the angle [0, 2Pi] of rotation represented by this quaternion.
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
#define CONETWIST_DEF_FIX_THRESH
btScalar m_swingCorrection
void setZ(btScalar _z)
Set the z value.
Jacobian entry is an abstraction that allows to describe constraints it can be used in combination wi...
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
btQuaternion inverse() const
Return the inverse of this quaternion.
void internalGetAngularVelocity(btVector3 &angVel) const
btScalar * m_J2angularAxis
btScalar dot(const btVector3 &v) const
Return the dot product.
btScalar * m_J2linearAxis
void internalApplyImpulse(const btVector3 &linearComponent, const btVector3 &angularComponent, const btScalar impulseMagnitude)
btScalar computeAngularImpulseDenominator(const btVector3 &axis, const btMatrix3x3 &invInertiaWorld)
btQuaternion & normalize()
Normalize the quaternion Such that x^2 + y^2 + z^2 +w^2 = 1.
const btTransform & getCenterOfMassTransform() const
btVector3 GetPointForAngle(btScalar fAngleInRadians, btScalar fLength) const
const T & btMax(const T &a, const T &b)
const btScalar & y() const
Return the y value.
btVector3 m_accMotorImpulse
void internalGetVelocityInLocalPointObsolete(const btVector3 &rel_pos, btVector3 &velocity) const
const btVector3 & getInvInertiaDiagLocal() const
btScalar m_twistLimitRatio
btScalar m_twistCorrection
btScalar btSin(btScalar x)
void calcAngleInfo2(const btTransform &transA, const btTransform &transB, const btMatrix3x3 &invInertiaWorldA, const btMatrix3x3 &invInertiaWorldB)
btScalar m_accTwistLimitImpulse
btScalar btFabs(btScalar x)
btScalar m_twistLimitSign
btQuaternion shortestArcQuat(const btVector3 &v0, const btVector3 &v1)
#define CONETWIST_USE_OBSOLETE_SOLVER
void adjustSwingAxisToUseEllipseNormal(btVector3 &vSwingAxis) const
void computeConeLimitInfo(const btQuaternion &qCone, btScalar &swingAngle, btVector3 &vSwingAxis, btScalar &swingLimit)
btScalar m_maxMotorImpulse
btScalar btCos(btScalar x)
void setY(btScalar _y)
Set the y value.
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
void setMotorTarget(const btQuaternion &q)
btScalar * m_constraintError
btMatrix3x3 transpose() const
Return the transpose of the matrix.
btScalar getInvMass() const
void setMotorTargetInConstraintSpace(const btQuaternion &q)
btVector3 getColumn(int i) const
Get a column of the matrix as a vector.
btScalar getDiagonal() const
btVector3 can be used to represent 3D points and vectors.
virtual void getInfo1(btConstraintInfo1 *info)
internal method used by the constraint solver, don't use them directly
void computeTwistLimitInfo(const btQuaternion &qTwist, btScalar &twistAngle, btVector3 &vTwistAxis)
const btRigidBody & getRigidBodyA() const
bool btFuzzyZero(btScalar x)
btScalar m_appliedImpulse
const btScalar & x() const
Return the x value.
btScalar m_swingLimitRatio
void setLimit(int limitIndex, btScalar limitValue)
#define SIMD_FORCE_INLINE
const btScalar & x() const
Return the x value.
btConeTwistConstraint(btRigidBody &rbA, btRigidBody &rbB, const btTransform &rbAFrame, const btTransform &rbBFrame)
virtual void getInfo2(btConstraintInfo2 *info)
internal method used by the constraint solver, don't use them directly
void updateRHS(btScalar timeStep)
virtual void setFrames(const btTransform &frameA, const btTransform &frameB)
const btMatrix3x3 & getInvInertiaTensorWorld() const
void getInfo1NonVirtual(btConstraintInfo1 *info)
const btVector3 & getCenterOfMassPosition() const
void getInfo2NonVirtual(btConstraintInfo2 *info, const btTransform &transA, const btTransform &transB, const btMatrix3x3 &invInertiaWorldA, const btMatrix3x3 &invInertiaWorldB)
btScalar btAtan2(btScalar x, btScalar y)
btScalar m_accSwingLimitImpulse
btScalar * m_J1angularAxis
static btVector3 vTwist(1, 0, 0)
const btScalar & z() const
Return the z value.
void getSkewSymmetricMatrix(btVector3 *v0, btVector3 *v1, btVector3 *v2) const
btScalar btAtan2Fast(btScalar y, btScalar x)
btVector3 m_linearJointAxis
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...
bool m_useSolveConstraintObsolete
btScalar m_relaxationFactor
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
virtual void buildJacobian()
internal method used by the constraint solver, don't use them directly
const btScalar & z() const
Return the z value.
btScalar computeAngularImpulseDenominator(const btVector3 &axis) const
btScalar length2() const
Return the length of the vector squared.
btVector3 quatRotate(const btQuaternion &rotation, const btVector3 &v)