Merge pull request #398 from MakoEnergy/master
Constraint Accessibility.
This commit is contained in:
@@ -171,6 +171,11 @@ public:
|
|||||||
m_angularOnly = angularOnly;
|
m_angularOnly = angularOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getAngularOnly() const
|
||||||
|
{
|
||||||
|
return m_angularOnly;
|
||||||
|
}
|
||||||
|
|
||||||
void setLimit(int limitIndex,btScalar limitValue)
|
void setLimit(int limitIndex,btScalar limitValue)
|
||||||
{
|
{
|
||||||
switch (limitIndex)
|
switch (limitIndex)
|
||||||
@@ -196,6 +201,33 @@ public:
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btScalar getLimit(int limitIndex) const
|
||||||
|
{
|
||||||
|
switch (limitIndex)
|
||||||
|
{
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
return m_twistSpan;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
return m_swingSpan2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
return m_swingSpan1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
btAssert(0 && "Invalid limitIndex specified for btConeTwistConstraint");
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// setLimit(), a few notes:
|
// setLimit(), a few notes:
|
||||||
// _softness:
|
// _softness:
|
||||||
// 0->1, recommend ~0.8->1.
|
// 0->1, recommend ~0.8->1.
|
||||||
@@ -218,8 +250,8 @@ public:
|
|||||||
m_relaxationFactor = _relaxationFactor;
|
m_relaxationFactor = _relaxationFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const btTransform& getAFrame() { return m_rbAFrame; };
|
const btTransform& getAFrame() const { return m_rbAFrame; };
|
||||||
const btTransform& getBFrame() { return m_rbBFrame; };
|
const btTransform& getBFrame() const { return m_rbBFrame; };
|
||||||
|
|
||||||
inline int getSolveTwistLimit()
|
inline int getSolveTwistLimit()
|
||||||
{
|
{
|
||||||
@@ -239,27 +271,43 @@ public:
|
|||||||
void calcAngleInfo();
|
void calcAngleInfo();
|
||||||
void calcAngleInfo2(const btTransform& transA, const btTransform& transB,const btMatrix3x3& invInertiaWorldA,const btMatrix3x3& invInertiaWorldB);
|
void calcAngleInfo2(const btTransform& transA, const btTransform& transB,const btMatrix3x3& invInertiaWorldA,const btMatrix3x3& invInertiaWorldB);
|
||||||
|
|
||||||
inline btScalar getSwingSpan1()
|
inline btScalar getSwingSpan1() const
|
||||||
{
|
{
|
||||||
return m_swingSpan1;
|
return m_swingSpan1;
|
||||||
}
|
}
|
||||||
inline btScalar getSwingSpan2()
|
inline btScalar getSwingSpan2() const
|
||||||
{
|
{
|
||||||
return m_swingSpan2;
|
return m_swingSpan2;
|
||||||
}
|
}
|
||||||
inline btScalar getTwistSpan()
|
inline btScalar getTwistSpan() const
|
||||||
{
|
{
|
||||||
return m_twistSpan;
|
return m_twistSpan;
|
||||||
}
|
}
|
||||||
inline btScalar getTwistAngle()
|
inline btScalar getLimitSoftness() const
|
||||||
|
{
|
||||||
|
return m_limitSoftness;
|
||||||
|
}
|
||||||
|
inline btScalar getBiasFactor() const
|
||||||
|
{
|
||||||
|
return m_biasFactor;
|
||||||
|
}
|
||||||
|
inline btScalar getRelaxationFactor() const
|
||||||
|
{
|
||||||
|
return m_relaxationFactor;
|
||||||
|
}
|
||||||
|
inline btScalar getTwistAngle() const
|
||||||
{
|
{
|
||||||
return m_twistAngle;
|
return m_twistAngle;
|
||||||
}
|
}
|
||||||
bool isPastSwingLimit() { return m_solveSwingLimit; }
|
bool isPastSwingLimit() { return m_solveSwingLimit; }
|
||||||
|
|
||||||
|
btScalar getDamping() const { return m_damping; }
|
||||||
void setDamping(btScalar damping) { m_damping = damping; }
|
void setDamping(btScalar damping) { m_damping = damping; }
|
||||||
|
|
||||||
void enableMotor(bool b) { m_bMotorEnabled = b; }
|
void enableMotor(bool b) { m_bMotorEnabled = b; }
|
||||||
|
bool isMotorEnabled() const { return m_bMotorEnabled; }
|
||||||
|
btScalar getMaxMotorImpulse() const { return m_maxMotorImpulse; }
|
||||||
|
bool isMaxMotorImpulseNormalized() const { return m_bNormalizedMotorStrength; }
|
||||||
void setMaxMotorImpulse(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; m_bNormalizedMotorStrength = false; }
|
void setMaxMotorImpulse(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; m_bNormalizedMotorStrength = false; }
|
||||||
void setMaxMotorImpulseNormalized(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; m_bNormalizedMotorStrength = true; }
|
void setMaxMotorImpulseNormalized(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; m_bNormalizedMotorStrength = true; }
|
||||||
|
|
||||||
@@ -271,6 +319,7 @@ public:
|
|||||||
// note: if q violates the joint limits, the internal target is clamped to avoid conflicting impulses (very bad for stability)
|
// note: if q violates the joint limits, the internal target is clamped to avoid conflicting impulses (very bad for stability)
|
||||||
// note: don't forget to enableMotor()
|
// note: don't forget to enableMotor()
|
||||||
void setMotorTarget(const btQuaternion &q);
|
void setMotorTarget(const btQuaternion &q);
|
||||||
|
const btQuaternion& getMotorTarget() const { return m_qTarget; }
|
||||||
|
|
||||||
// same as above, but q is the desired rotation of frameA wrt frameB in constraint space
|
// same as above, but q is the desired rotation of frameA wrt frameB in constraint space
|
||||||
void setMotorTargetInConstraintSpace(const btQuaternion &q);
|
void setMotorTargetInConstraintSpace(const btQuaternion &q);
|
||||||
@@ -297,6 +346,11 @@ public:
|
|||||||
///return the local value of parameter
|
///return the local value of parameter
|
||||||
virtual btScalar getParam(int num, int axis = -1) const;
|
virtual btScalar getParam(int num, int axis = -1) const;
|
||||||
|
|
||||||
|
int getFlags() const
|
||||||
|
{
|
||||||
|
return m_flags;
|
||||||
|
}
|
||||||
|
|
||||||
virtual int calculateSerializeBufferSize() const;
|
virtual int calculateSerializeBufferSize() const;
|
||||||
|
|
||||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||||
|
|||||||
@@ -111,14 +111,14 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//! Is limited
|
//! Is limited
|
||||||
bool isLimited()
|
bool isLimited() const
|
||||||
{
|
{
|
||||||
if(m_loLimit > m_hiLimit) return false;
|
if(m_loLimit > m_hiLimit) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Need apply correction
|
//! Need apply correction
|
||||||
bool needApplyTorques()
|
bool needApplyTorques() const
|
||||||
{
|
{
|
||||||
if(m_currentLimit == 0 && m_enableMotor == false) return false;
|
if(m_currentLimit == 0 && m_enableMotor == false) return false;
|
||||||
return true;
|
return true;
|
||||||
@@ -207,11 +207,11 @@ public:
|
|||||||
- limited means upper > lower
|
- limited means upper > lower
|
||||||
- limitIndex: first 3 are linear, next 3 are angular
|
- limitIndex: first 3 are linear, next 3 are angular
|
||||||
*/
|
*/
|
||||||
inline bool isLimited(int limitIndex)
|
inline bool isLimited(int limitIndex) const
|
||||||
{
|
{
|
||||||
return (m_upperLimit[limitIndex] >= m_lowerLimit[limitIndex]);
|
return (m_upperLimit[limitIndex] >= m_lowerLimit[limitIndex]);
|
||||||
}
|
}
|
||||||
inline bool needApplyForce(int limitIndex)
|
inline bool needApplyForce(int limitIndex) const
|
||||||
{
|
{
|
||||||
if(m_currentLimit[limitIndex] == 0 && m_enableMotor[limitIndex] == false) return false;
|
if(m_currentLimit[limitIndex] == 0 && m_enableMotor[limitIndex] == false) return false;
|
||||||
return true;
|
return true;
|
||||||
@@ -457,7 +457,7 @@ public:
|
|||||||
m_linearLimits.m_lowerLimit = linearLower;
|
m_linearLimits.m_lowerLimit = linearLower;
|
||||||
}
|
}
|
||||||
|
|
||||||
void getLinearLowerLimit(btVector3& linearLower)
|
void getLinearLowerLimit(btVector3& linearLower) const
|
||||||
{
|
{
|
||||||
linearLower = m_linearLimits.m_lowerLimit;
|
linearLower = m_linearLimits.m_lowerLimit;
|
||||||
}
|
}
|
||||||
@@ -467,7 +467,7 @@ public:
|
|||||||
m_linearLimits.m_upperLimit = linearUpper;
|
m_linearLimits.m_upperLimit = linearUpper;
|
||||||
}
|
}
|
||||||
|
|
||||||
void getLinearUpperLimit(btVector3& linearUpper)
|
void getLinearUpperLimit(btVector3& linearUpper) const
|
||||||
{
|
{
|
||||||
linearUpper = m_linearLimits.m_upperLimit;
|
linearUpper = m_linearLimits.m_upperLimit;
|
||||||
}
|
}
|
||||||
@@ -478,7 +478,7 @@ public:
|
|||||||
m_angularLimits[i].m_loLimit = btNormalizeAngle(angularLower[i]);
|
m_angularLimits[i].m_loLimit = btNormalizeAngle(angularLower[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void getAngularLowerLimit(btVector3& angularLower)
|
void getAngularLowerLimit(btVector3& angularLower) const
|
||||||
{
|
{
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
angularLower[i] = m_angularLimits[i].m_loLimit;
|
angularLower[i] = m_angularLimits[i].m_loLimit;
|
||||||
@@ -490,7 +490,7 @@ public:
|
|||||||
m_angularLimits[i].m_hiLimit = btNormalizeAngle(angularUpper[i]);
|
m_angularLimits[i].m_hiLimit = btNormalizeAngle(angularUpper[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void getAngularUpperLimit(btVector3& angularUpper)
|
void getAngularUpperLimit(btVector3& angularUpper) const
|
||||||
{
|
{
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
angularUpper[i] = m_angularLimits[i].m_hiLimit;
|
angularUpper[i] = m_angularLimits[i].m_hiLimit;
|
||||||
@@ -532,7 +532,7 @@ public:
|
|||||||
- limited means upper > lower
|
- limited means upper > lower
|
||||||
- limitIndex: first 3 are linear, next 3 are angular
|
- limitIndex: first 3 are linear, next 3 are angular
|
||||||
*/
|
*/
|
||||||
bool isLimited(int limitIndex)
|
bool isLimited(int limitIndex) const
|
||||||
{
|
{
|
||||||
if(limitIndex<3)
|
if(limitIndex<3)
|
||||||
{
|
{
|
||||||
@@ -549,9 +549,12 @@ public:
|
|||||||
btConstraintInfo2 *info, int row, btVector3& ax1, int rotational, int rotAllowed = false);
|
btConstraintInfo2 *info, int row, btVector3& ax1, int rotational, int rotAllowed = false);
|
||||||
|
|
||||||
// access for UseFrameOffset
|
// access for UseFrameOffset
|
||||||
bool getUseFrameOffset() { return m_useOffsetForConstraintFrame; }
|
bool getUseFrameOffset() const { return m_useOffsetForConstraintFrame; }
|
||||||
void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; }
|
void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; }
|
||||||
|
|
||||||
|
bool getUseLinearReferenceFrameA() const { return m_useLinearReferenceFrameA; }
|
||||||
|
void setUseLinearReferenceFrameA(bool linearReferenceFrameA) { m_useLinearReferenceFrameA = linearReferenceFrameA; }
|
||||||
|
|
||||||
///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5).
|
///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5).
|
||||||
///If no axis is provided, it uses the default axis for this constraint.
|
///If no axis is provided, it uses the default axis for this constraint.
|
||||||
virtual void setParam(int num, btScalar value, int axis = -1);
|
virtual void setParam(int num, btScalar value, int axis = -1);
|
||||||
@@ -560,6 +563,10 @@ public:
|
|||||||
|
|
||||||
void setAxis( const btVector3& axis1, const btVector3& axis2);
|
void setAxis( const btVector3& axis1, const btVector3& axis2);
|
||||||
|
|
||||||
|
virtual int getFlags() const
|
||||||
|
{
|
||||||
|
return m_flags;
|
||||||
|
}
|
||||||
|
|
||||||
virtual int calculateSerializeBufferSize() const;
|
virtual int calculateSerializeBufferSize() const;
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,26 @@ public:
|
|||||||
void setEquilibriumPoint(int index); // set the current constraint position/orientation as an equilibrium point for given DOF
|
void setEquilibriumPoint(int index); // set the current constraint position/orientation as an equilibrium point for given DOF
|
||||||
void setEquilibriumPoint(int index, btScalar val);
|
void setEquilibriumPoint(int index, btScalar val);
|
||||||
|
|
||||||
|
bool isSpringEnabled(int index) const
|
||||||
|
{
|
||||||
|
return m_springEnabled[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
btScalar getStiffness(int index) const
|
||||||
|
{
|
||||||
|
return m_springStiffness[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
btScalar getDamping(int index) const
|
||||||
|
{
|
||||||
|
return m_springDamping[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
btScalar getEquilibriumPoint(int index) const
|
||||||
|
{
|
||||||
|
return m_equilibriumPoint[index];
|
||||||
|
}
|
||||||
|
|
||||||
virtual void setAxis( const btVector3& axis1, const btVector3& axis2);
|
virtual void setAxis( const btVector3& axis1, const btVector3& axis2);
|
||||||
|
|
||||||
virtual void getInfo2 (btConstraintInfo2* info);
|
virtual void getInfo2 (btConstraintInfo2* info);
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ public:
|
|||||||
// maintain a given angular target.
|
// maintain a given angular target.
|
||||||
void enableMotor(bool enableMotor) { m_enableAngularMotor = enableMotor; }
|
void enableMotor(bool enableMotor) { m_enableAngularMotor = enableMotor; }
|
||||||
void setMaxMotorImpulse(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; }
|
void setMaxMotorImpulse(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; }
|
||||||
|
void setMotorTargetVelocity(btScalar motorTargetVelocity) { m_motorTargetVelocity = motorTargetVelocity; }
|
||||||
void setMotorTarget(const btQuaternion& qAinB, btScalar dt); // qAinB is rotation of body A wrt body B.
|
void setMotorTarget(const btQuaternion& qAinB, btScalar dt); // qAinB is rotation of body A wrt body B.
|
||||||
void setMotorTarget(btScalar targetAngle, btScalar dt);
|
void setMotorTarget(btScalar targetAngle, btScalar dt);
|
||||||
|
|
||||||
@@ -194,6 +195,33 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btScalar getLimitSoftness() const
|
||||||
|
{
|
||||||
|
#ifdef _BT_USE_CENTER_LIMIT_
|
||||||
|
return m_limit.getSoftness();
|
||||||
|
#else
|
||||||
|
return m_limitSoftness;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
btScalar getLimitBiasFactor() const
|
||||||
|
{
|
||||||
|
#ifdef _BT_USE_CENTER_LIMIT_
|
||||||
|
return m_limit.getBiasFactor();
|
||||||
|
#else
|
||||||
|
return m_biasFactor;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
btScalar getLimitRelaxationFactor() const
|
||||||
|
{
|
||||||
|
#ifdef _BT_USE_CENTER_LIMIT_
|
||||||
|
return m_limit.getRelaxationFactor();
|
||||||
|
#else
|
||||||
|
return m_relaxationFactor;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void setAxis(btVector3& axisInA)
|
void setAxis(btVector3& axisInA)
|
||||||
{
|
{
|
||||||
btVector3 rbAxisA1, rbAxisA2;
|
btVector3 rbAxisA1, rbAxisA2;
|
||||||
@@ -297,7 +325,9 @@ public:
|
|||||||
// access for UseFrameOffset
|
// access for UseFrameOffset
|
||||||
bool getUseFrameOffset() { return m_useOffsetForConstraintFrame; }
|
bool getUseFrameOffset() { return m_useOffsetForConstraintFrame; }
|
||||||
void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; }
|
void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; }
|
||||||
|
// access for UseReferenceFrameA
|
||||||
|
bool getUseReferenceFrameA() const { return m_useReferenceFrameA; }
|
||||||
|
void setUseReferenceFrameA(bool useReferenceFrameA) { m_useReferenceFrameA = useReferenceFrameA; }
|
||||||
|
|
||||||
///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5).
|
///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5).
|
||||||
///If no axis is provided, it uses the default axis for this constraint.
|
///If no axis is provided, it uses the default axis for this constraint.
|
||||||
@@ -305,6 +335,11 @@ public:
|
|||||||
///return the local value of parameter
|
///return the local value of parameter
|
||||||
virtual btScalar getParam(int num, int axis = -1) const;
|
virtual btScalar getParam(int num, int axis = -1) const;
|
||||||
|
|
||||||
|
virtual int getFlags() const
|
||||||
|
{
|
||||||
|
return m_flags;
|
||||||
|
}
|
||||||
|
|
||||||
virtual int calculateSerializeBufferSize() const;
|
virtual int calculateSerializeBufferSize() const;
|
||||||
|
|
||||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||||
|
|||||||
@@ -117,6 +117,11 @@ public:
|
|||||||
///return the local value of parameter
|
///return the local value of parameter
|
||||||
virtual btScalar getParam(int num, int axis = -1) const;
|
virtual btScalar getParam(int num, int axis = -1) const;
|
||||||
|
|
||||||
|
virtual int getFlags() const
|
||||||
|
{
|
||||||
|
return m_flags;
|
||||||
|
}
|
||||||
|
|
||||||
virtual int calculateSerializeBufferSize() const;
|
virtual int calculateSerializeBufferSize() const;
|
||||||
|
|
||||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||||
|
|||||||
@@ -281,6 +281,11 @@ public:
|
|||||||
///return the local value of parameter
|
///return the local value of parameter
|
||||||
virtual btScalar getParam(int num, int axis = -1) const;
|
virtual btScalar getParam(int num, int axis = -1) const;
|
||||||
|
|
||||||
|
virtual int getFlags() const
|
||||||
|
{
|
||||||
|
return m_flags;
|
||||||
|
}
|
||||||
|
|
||||||
virtual int calculateSerializeBufferSize() const;
|
virtual int calculateSerializeBufferSize() const;
|
||||||
|
|
||||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||||
|
|||||||
Reference in New Issue
Block a user