41 #ifndef BT_GENERIC_6DOF_CONSTRAINT2_H 42 #define BT_GENERIC_6DOF_CONSTRAINT2_H 51 #ifdef BT_USE_DOUBLE_PRECISION 52 #define btGeneric6DofSpring2ConstraintData2 btGeneric6DofSpring2ConstraintDoubleData2 53 #define btGeneric6DofSpring2ConstraintDataName "btGeneric6DofSpring2ConstraintDoubleData2" 55 #define btGeneric6DofSpring2ConstraintData2 btGeneric6DofSpring2ConstraintData 56 #define btGeneric6DofSpring2ConstraintDataName "btGeneric6DofSpring2ConstraintData" 57 #endif //BT_USE_DOUBLE_PRECISION 108 m_enableMotor =
false;
109 m_targetVelocity = 0;
110 m_maxMotorForce = 6.0f;
111 m_servoMotor =
false;
113 m_enableSpring =
false;
114 m_springStiffness = 0;
115 m_springStiffnessLimited =
false;
117 m_springDampingLimited =
false;
118 m_equilibriumPoint = 0;
120 m_currentLimitError = 0;
121 m_currentLimitErrorHi = 0;
122 m_currentPosition = 0;
156 if(m_loLimit > m_hiLimit)
return false;
197 m_lowerLimit .
setValue(0.f , 0.f , 0.f );
198 m_upperLimit .
setValue(0.f , 0.f , 0.f );
199 m_bounce .
setValue(0.f , 0.f , 0.f );
200 m_stopERP .
setValue(0.2f, 0.2f, 0.2f);
201 m_stopCFM .
setValue(0.f , 0.f , 0.f );
202 m_motorERP .
setValue(0.9f, 0.9f, 0.9f);
203 m_motorCFM .
setValue(0.f , 0.f , 0.f );
205 m_currentLimitError .
setValue(0.f , 0.f , 0.f );
206 m_currentLimitErrorHi.
setValue(0.f , 0.f , 0.f );
207 m_currentLinearDiff .
setValue(0.f , 0.f , 0.f );
209 for(
int i=0; i < 3; i++)
211 m_enableMotor[i] =
false;
212 m_servoMotor[i] =
false;
213 m_enableSpring[i] =
false;
215 m_springStiffness[i] =
btScalar(0.f);
216 m_springStiffnessLimited[i] =
false;
218 m_springDampingLimited[i] =
false;
219 m_equilibriumPoint[i] =
btScalar(0.f);
220 m_targetVelocity[i] =
btScalar(0.f);
223 m_currentLimit[i] = 0;
241 for(
int i=0; i < 3; i++)
261 return (m_upperLimit[limitIndex] >= m_lowerLimit[limitIndex]);
274 #define BT_6DOF_FLAGS_AXIS_SHIFT2 4 // bits per axis 313 void calculateLinearInfo();
314 void calculateAngleInfo();
315 void testAngularLimitMotor(
int axis_index);
332 virtual int calculateSerializeBufferSize()
const;
333 virtual const char* serialize(
void* dataBuffer,
btSerializer* serializer)
const;
340 void calculateTransforms();
371 for(
int i = 0; i < 3; i++)
377 for(
int i = 0; i < 3; i++)
383 for(
int i = 0; i < 3; i++)
384 angularLower[i] = m_angularLimits[i].
m_loLimit;
389 for(
int i = 0; i < 3; i++)
390 angularLower[i] = -m_angularLimits[i].
m_hiLimit;
395 for(
int i = 0; i < 3; i++)
401 for(
int i = 0; i < 3; i++)
407 for(
int i = 0; i < 3; i++)
408 angularUpper[i] = m_angularLimits[i].
m_hiLimit;
413 for(
int i = 0; i < 3; i++)
414 angularUpper[i] = -m_angularLimits[i].
m_loLimit;
455 return m_linearLimits.
isLimited(limitIndex);
457 return m_angularLimits[limitIndex-3].
isLimited();
465 void setBounce(
int index,
btScalar bounce);
467 void enableMotor(
int index,
bool onOff);
468 void setServo(
int index,
bool onOff);
469 void setTargetVelocity(
int index,
btScalar velocity);
470 void setServoTarget(
int index,
btScalar target);
471 void setMaxMotorForce(
int index,
btScalar force);
473 void enableSpring(
int index,
bool onOff);
474 void setStiffness(
int index,
btScalar stiffness,
bool limitIfNeeded =
true);
475 void setDamping(
int index,
btScalar damping,
bool limitIfNeeded =
true);
476 void setEquilibriumPoint();
477 void setEquilibriumPoint(
int index);
478 void setEquilibriumPoint(
int index,
btScalar val);
482 virtual void setParam(
int num,
btScalar value,
int axis = -1);
483 virtual btScalar getParam(
int num,
int axis = -1)
const;
514 char m_linearEnableMotor[4];
515 char m_linearServoMotor[4];
516 char m_linearEnableSpring[4];
517 char m_linearSpringStiffnessLimited[4];
518 char m_linearSpringDampingLimited[4];
534 char m_angularEnableMotor[4];
535 char m_angularServoMotor[4];
536 char m_angularEnableSpring[4];
537 char m_angularSpringStiffnessLimited[4];
538 char m_angularSpringDampingLimited[4];
562 char m_linearEnableMotor[4];
563 char m_linearServoMotor[4];
564 char m_linearEnableSpring[4];
565 char m_linearSpringStiffnessLimited[4];
566 char m_linearSpringDampingLimited[4];
582 char m_angularEnableMotor[4];
583 char m_angularServoMotor[4];
584 char m_angularEnableSpring[4];
585 char m_angularSpringStiffnessLimited[4];
586 char m_angularSpringDampingLimited[4];
601 m_frameInA.serialize(dof->m_rbAFrame);
602 m_frameInB.serialize(dof->m_rbBFrame);
607 dof->m_angularLowerLimit.m_floats[i] = m_angularLimits[i].m_loLimit;
608 dof->m_angularUpperLimit.m_floats[i] = m_angularLimits[i].m_hiLimit;
609 dof->m_angularBounce.m_floats[i] = m_angularLimits[i].m_bounce;
610 dof->m_angularStopERP.m_floats[i] = m_angularLimits[i].m_stopERP;
611 dof->m_angularStopCFM.m_floats[i] = m_angularLimits[i].m_stopCFM;
612 dof->m_angularMotorERP.m_floats[i] = m_angularLimits[i].m_motorERP;
613 dof->m_angularMotorCFM.m_floats[i] = m_angularLimits[i].m_motorCFM;
614 dof->m_angularTargetVelocity.m_floats[i] = m_angularLimits[i].m_targetVelocity;
615 dof->m_angularMaxMotorForce.m_floats[i] = m_angularLimits[i].m_maxMotorForce;
616 dof->m_angularServoTarget.m_floats[i] = m_angularLimits[i].m_servoTarget;
617 dof->m_angularSpringStiffness.m_floats[i] = m_angularLimits[i].m_springStiffness;
618 dof->m_angularSpringDamping.m_floats[i] = m_angularLimits[i].m_springDamping;
619 dof->m_angularEquilibriumPoint.m_floats[i] = m_angularLimits[i].m_equilibriumPoint;
621 dof->m_angularLowerLimit.m_floats[3] = 0;
622 dof->m_angularUpperLimit.m_floats[3] = 0;
623 dof->m_angularBounce.m_floats[3] = 0;
624 dof->m_angularStopERP.m_floats[3] = 0;
625 dof->m_angularStopCFM.m_floats[3] = 0;
626 dof->m_angularMotorERP.m_floats[3] = 0;
627 dof->m_angularMotorCFM.m_floats[3] = 0;
628 dof->m_angularTargetVelocity.m_floats[3] = 0;
629 dof->m_angularMaxMotorForce.m_floats[3] = 0;
630 dof->m_angularServoTarget.m_floats[3] = 0;
631 dof->m_angularSpringStiffness.m_floats[3] = 0;
632 dof->m_angularSpringDamping.m_floats[3] = 0;
633 dof->m_angularEquilibriumPoint.m_floats[3] = 0;
636 dof->m_angularEnableMotor[i] = i < 3 ? ( m_angularLimits[i].m_enableMotor ? 1 : 0 ) : 0;
637 dof->m_angularServoMotor[i] = i < 3 ? ( m_angularLimits[i].m_servoMotor ? 1 : 0 ) : 0;
638 dof->m_angularEnableSpring[i] = i < 3 ? ( m_angularLimits[i].m_enableSpring ? 1 : 0 ) : 0;
639 dof->m_angularSpringStiffnessLimited[i] = i < 3 ? ( m_angularLimits[i].m_springStiffnessLimited ? 1 : 0 ) : 0;
640 dof->m_angularSpringDampingLimited[i] = i < 3 ? ( m_angularLimits[i].m_springDampingLimited ? 1 : 0 ) : 0;
643 m_linearLimits.m_lowerLimit.serialize( dof->m_linearLowerLimit );
644 m_linearLimits.m_upperLimit.serialize( dof->m_linearUpperLimit );
645 m_linearLimits.m_bounce.serialize( dof->m_linearBounce );
646 m_linearLimits.m_stopERP.serialize( dof->m_linearStopERP );
647 m_linearLimits.m_stopCFM.serialize( dof->m_linearStopCFM );
648 m_linearLimits.m_motorERP.serialize( dof->m_linearMotorERP );
649 m_linearLimits.m_motorCFM.serialize( dof->m_linearMotorCFM );
650 m_linearLimits.m_targetVelocity.serialize( dof->m_linearTargetVelocity );
651 m_linearLimits.m_maxMotorForce.serialize( dof->m_linearMaxMotorForce );
652 m_linearLimits.m_servoTarget.serialize( dof->m_linearServoTarget );
653 m_linearLimits.m_springStiffness.serialize( dof->m_linearSpringStiffness );
654 m_linearLimits.m_springDamping.serialize( dof->m_linearSpringDamping );
655 m_linearLimits.m_equilibriumPoint.serialize( dof->m_linearEquilibriumPoint );
658 dof->m_linearEnableMotor[i] = i < 3 ? ( m_linearLimits.m_enableMotor[i] ? 1 : 0 ) : 0;
659 dof->m_linearServoMotor[i] = i < 3 ? ( m_linearLimits.m_servoMotor[i] ? 1 : 0 ) : 0;
660 dof->m_linearEnableSpring[i] = i < 3 ? ( m_linearLimits.m_enableSpring[i] ? 1 : 0 ) : 0;
661 dof->m_linearSpringStiffnessLimited[i] = i < 3 ? ( m_linearLimits.m_springStiffnessLimited[i] ? 1 : 0 ) : 0;
662 dof->m_linearSpringDampingLimited[i] = i < 3 ? ( m_linearLimits.m_springDampingLimited[i] ? 1 : 0 ) : 0;
665 dof->m_rotateOrder = m_rotateOrder;
667 dof->m_padding1[0] = 0;
668 dof->m_padding1[1] = 0;
669 dof->m_padding1[2] = 0;
670 dof->m_padding1[3] = 0;
679 #endif //BT_GENERIC_6DOF_CONSTRAINT_H
btVector3FloatData m_angularUpperLimit
void getAngularUpperLimitReversed(btVector3 &angularUpper)
btTransformDoubleData m_rbBFrame
void getAngularLowerLimitReversed(btVector3 &angularLower)
btVector3 m_maxMotorForce
btVector3FloatData m_linearBounce
btVector3DoubleData m_linearEquilibriumPoint
btVector3 m_springStiffness
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
btTypedConstraintData m_typeConstraintData
Jacobian entry is an abstraction that allows to describe constraints it can be used in combination wi...
btVector3DoubleData m_linearMotorCFM
btVector3FloatData m_linearSpringStiffness
btVector3FloatData m_linearEquilibriumPoint
btVector3DoubleData m_linearSpringDamping
btVector3FloatData m_linearLowerLimit
void setLimit(int axis, btScalar lo, btScalar hi)
btTransform & getFrameOffsetB()
btTransformFloatData m_rbBFrame
btVector3DoubleData m_linearUpperLimit
btVector3FloatData m_linearTargetVelocity
btGeneric6DofSpring2Constraint & operator=(btGeneric6DofSpring2Constraint &)
btTransformDoubleData m_rbAFrame
const btTransform & getFrameOffsetA() const
bool m_springStiffnessLimited[3]
btVector3DoubleData m_angularMotorERP
btScalar btGetMatrixElem(const btMatrix3x3 &mat, int index)
void setAngularLowerLimitReversed(const btVector3 &angularLower)
bool m_springStiffnessLimited
btVector3FloatData m_angularLowerLimit
btVector3 m_springDamping
btTypedConstraintDoubleData m_typeConstraintData
const btTransform & getFrameOffsetB() const
btVector3DoubleData m_angularEquilibriumPoint
btVector3FloatData m_angularServoTarget
void getLinearLowerLimit(btVector3 &linearLower)
#define SIMD_FORCE_INLINE
btVector3DoubleData m_angularServoTarget
btVector3 getAxis(int axis_index) const
bool m_springDampingLimited[3]
btVector3FloatData m_angularMaxMotorForce
btVector3FloatData m_angularBounce
btVector3DoubleData m_linearTargetVelocity
btVector3DoubleData m_angularStopCFM
btVector3FloatData m_angularMotorCFM
btTranslationalLimitMotor2 m_linearLimits
btVector3DoubleData m_linearBounce
btRotationalLimitMotor2(const btRotationalLimitMotor2 &limot)
RotateOrder getRotationOrder()
btTransform & getFrameOffsetA()
btVector3DoubleData m_linearMotorERP
btVector3 m_currentLinearDiff
void getAngularUpperLimit(btVector3 &angularUpper)
void getLinearUpperLimit(btVector3 &linearUpper)
btVector3 m_calculatedLinearDiff
btVector3FloatData m_linearMaxMotorForce
btVector3FloatData m_linearMotorCFM
btVector3DoubleData m_angularLowerLimit
btScalar m_currentLimitError
btTranslationalLimitMotor2 * getTranslationalLimitMotor()
bool m_springDampingLimited
btVector3FloatData m_linearUpperLimit
btVector3FloatData m_angularStopCFM
bool isLimited(int limitIndex)
btVector3DoubleData m_linearMaxMotorForce
btVector3 m_currentLimitErrorHi
btTransform m_calculatedTransformB
btScalar m_currentLimitErrorHi
The btRigidBody is the main class for rigid body objects.
btVector3DoubleData m_linearLowerLimit
btTransform m_calculatedTransformA
void setLinearUpperLimit(const btVector3 &linearUpper)
btVector3 m_equilibriumPoint
btRotationalLimitMotor2 * getRotationalLimitMotor(int index)
this structure is not used, except for loading pre-2.82 .bullet files
btScalar m_targetVelocity
void setLinearLowerLimit(const btVector3 &linearLower)
void setAngularLowerLimit(const btVector3 &angularLower)
btVector3DoubleData m_angularMaxMotorForce
void setRotationOrder(RotateOrder order)
const btTransform & getCalculatedTransformB() const
btVector3FloatData m_angularTargetVelocity
btVector3FloatData m_linearMotorERP
virtual void buildJacobian()
internal method used by the constraint solver, don't use them directly
btVector3 m_currentLimitError
btVector3 can be used to represent 3D points and vectors.
#define ATTRIBUTE_ALIGNED16(a)
btVector3FloatData m_linearSpringDamping
btVector3FloatData m_linearStopCFM
btScalar btNormalizeAngle(btScalar angleInRadians)
btVector3FloatData m_linearServoTarget
#define btGeneric6DofSpring2ConstraintDataName
RotateOrder m_rotateOrder
bool matrixToEulerXYZ(const btMatrix3x3 &mat, btVector3 &xyz)
MatrixToEulerXYZ from http://www.geometrictools.com/LibFoundation/Mathematics/Wm4Matrix3.inl.html.
btVector3DoubleData m_linearServoTarget
btTransformFloatData m_rbAFrame
btVector3FloatData m_angularMotorERP
const btTransform & getCalculatedTransformA() const
btVector3FloatData m_angularEquilibriumPoint
TypedConstraint is the baseclass for Bullet constraints and vehicles.
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
void getAngularLowerLimit(btVector3 &angularLower)
btVector3 m_targetVelocity
btVector3DoubleData m_angularUpperLimit
#define BT_DECLARE_ALIGNED_ALLOCATOR()
btScalar m_equilibriumPoint
btVector3DoubleData m_angularSpringStiffness
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
#define btGeneric6DofSpring2ConstraintData2
bool isLimited(int limitIndex)
btVector3DoubleData m_angularMotorCFM
void setAngularUpperLimitReversed(const btVector3 &angularUpper)
btVector3FloatData m_angularSpringStiffness
btVector3DoubleData m_linearSpringStiffness
btVector3DoubleData m_angularStopERP
btVector3DoubleData m_angularSpringDamping
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
btScalar getRelativePivotPosition(int axis_index) const
void testLimitValue(btScalar test_value)
btScalar m_currentPosition
void setAngularUpperLimit(const btVector3 &angularUpper)
btVector3DoubleData m_angularBounce
btVector3FloatData m_linearStopERP
btScalar m_springStiffness
btVector3FloatData m_angularStopERP
void setLimitReversed(int axis, btScalar lo, btScalar hi)
virtual int calculateSerializeBufferSize() const
btTranslationalLimitMotor2()
btVector3 m_calculatedAxisAngleDiff
btVector3DoubleData m_angularTargetVelocity
btVector3DoubleData m_linearStopERP
btRotationalLimitMotor2()
btVector3FloatData m_angularSpringDamping
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btTranslationalLimitMotor2(const btTranslationalLimitMotor2 &other)
btVector3DoubleData m_linearStopCFM
btScalar getAngle(int axis_index) const