add operator != and operator == to btQuadWord,
minor fix in btTransformUtil::calculateVelocityQuaternion, report zero angular velocity on identical transforms (using above operator to check identical transforms)
This commit is contained in:
@@ -54,8 +54,7 @@ class btQuadWord : public btQuadWordStorage
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// SIMD_FORCE_INLINE btScalar& operator[](int i) { return (&m_floats[0])[i]; }
|
|
||||||
// SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_floats[0])[i]; }
|
|
||||||
/**@brief Return the x value */
|
/**@brief Return the x value */
|
||||||
SIMD_FORCE_INLINE const btScalar& getX() const { return m_floats[0]; }
|
SIMD_FORCE_INLINE const btScalar& getX() const { return m_floats[0]; }
|
||||||
/**@brief Return the y value */
|
/**@brief Return the y value */
|
||||||
@@ -79,10 +78,21 @@ class btQuadWord : public btQuadWordStorage
|
|||||||
/**@brief Return the w value */
|
/**@brief Return the w value */
|
||||||
SIMD_FORCE_INLINE const btScalar& w() const { return m_floats[3]; }
|
SIMD_FORCE_INLINE const btScalar& w() const { return m_floats[3]; }
|
||||||
|
|
||||||
|
//SIMD_FORCE_INLINE btScalar& operator[](int i) { return (&m_floats[0])[i]; }
|
||||||
|
//SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_floats[0])[i]; }
|
||||||
|
///operator btScalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons.
|
||||||
SIMD_FORCE_INLINE operator btScalar *() { return &m_floats[0]; }
|
SIMD_FORCE_INLINE operator btScalar *() { return &m_floats[0]; }
|
||||||
SIMD_FORCE_INLINE operator const btScalar *() const { return &m_floats[0]; }
|
SIMD_FORCE_INLINE operator const btScalar *() const { return &m_floats[0]; }
|
||||||
|
|
||||||
|
SIMD_FORCE_INLINE bool operator==(const btQuadWord& other) const
|
||||||
|
{
|
||||||
|
return ((m_floats[3]==m_floats[3]) && (m_floats[2]==m_floats[2]) && (m_floats[1]==m_floats[1]) && (m_floats[0]==m_floats[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
SIMD_FORCE_INLINE bool operator!=(const btQuadWord& other) const
|
||||||
|
{
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
|
||||||
/**@brief Set x,y,z and zero w
|
/**@brief Set x,y,z and zero w
|
||||||
* @param x Value of x
|
* @param x Value of x
|
||||||
|
|||||||
@@ -104,11 +104,12 @@ public:
|
|||||||
}
|
}
|
||||||
/**@brief Add two quaternions
|
/**@brief Add two quaternions
|
||||||
* @param q The quaternion to add to this one */
|
* @param q The quaternion to add to this one */
|
||||||
btQuaternion& operator+=(const btQuaternion& q)
|
SIMD_FORCE_INLINE btQuaternion& operator+=(const btQuaternion& q)
|
||||||
{
|
{
|
||||||
m_floats[0] += q.x(); m_floats[1] += q.y(); m_floats[2] += q.z(); m_floats[3] += q.m_floats[3];
|
m_floats[0] += q.x(); m_floats[1] += q.y(); m_floats[2] += q.z(); m_floats[3] += q.m_floats[3];
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Subtract out a quaternion
|
/**@brief Subtract out a quaternion
|
||||||
* @param q The quaternion to subtract from this one */
|
* @param q The quaternion to subtract from this one */
|
||||||
btQuaternion& operator-=(const btQuaternion& q)
|
btQuaternion& operator-=(const btQuaternion& q)
|
||||||
|
|||||||
@@ -105,8 +105,14 @@ public:
|
|||||||
linVel = (pos1 - pos0) / timeStep;
|
linVel = (pos1 - pos0) / timeStep;
|
||||||
btVector3 axis;
|
btVector3 axis;
|
||||||
btScalar angle;
|
btScalar angle;
|
||||||
|
if (orn0 != orn1)
|
||||||
|
{
|
||||||
calculateDiffAxisAngleQuaternion(orn0,orn1,axis,angle);
|
calculateDiffAxisAngleQuaternion(orn0,orn1,axis,angle);
|
||||||
angVel = axis * angle / timeStep;
|
angVel = axis * angle / timeStep;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
angVel.setValue(0,0,0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calculateDiffAxisAngleQuaternion(const btQuaternion& orn0,const btQuaternion& orn1a,btVector3& axis,btScalar& angle)
|
static void calculateDiffAxisAngleQuaternion(const btQuaternion& orn0,const btQuaternion& orn1a,btVector3& axis,btScalar& angle)
|
||||||
|
|||||||
Reference in New Issue
Block a user