diff --git a/src/LinearMath/btMatrix3x3.h b/src/LinearMath/btMatrix3x3.h index c5f220b43..e45afc3c0 100644 --- a/src/LinearMath/btMatrix3x3.h +++ b/src/LinearMath/btMatrix3x3.h @@ -192,6 +192,15 @@ class btMatrix3x3 { btScalar(0.0), btScalar(1.0), btScalar(0.0), btScalar(0.0), btScalar(0.0), btScalar(1.0)); } + + static const btMatrix3x3& getIdentity() + { + static const btMatrix3x3 identityMatrix(btScalar(1.0), btScalar(0.0), btScalar(0.0), + btScalar(0.0), btScalar(1.0), btScalar(0.0), + btScalar(0.0), btScalar(0.0), btScalar(1.0)); + return identityMatrix; + } + /**@brief Fill the values of the matrix into a 9 element array * @param m The array to be filled */ void getOpenGLSubMatrix(btScalar *m) const diff --git a/src/LinearMath/btQuaternion.h b/src/LinearMath/btQuaternion.h index cc24b1ede..ea1fce71d 100644 --- a/src/LinearMath/btQuaternion.h +++ b/src/LinearMath/btQuaternion.h @@ -275,6 +275,12 @@ public: } } + static const btQuaternion& getIdentity() + { + static const btQuaternion identityQuat(btScalar(0.),btScalar(0.),btScalar(0.),btScalar(1.)); + return identityQuat; + } + SIMD_FORCE_INLINE const btScalar& getW() const { return m_floats[3]; } diff --git a/src/LinearMath/btTransform.h b/src/LinearMath/btTransform.h index 2bde9ce63..c4fe33eec 100644 --- a/src/LinearMath/btTransform.h +++ b/src/LinearMath/btTransform.h @@ -190,11 +190,10 @@ public: btTransform operator*(const btTransform& t) const; /**@brief Return an identity transform */ - static btTransform getIdentity() + static const btTransform& getIdentity() { - btTransform tr; - tr.setIdentity(); - return tr; + static const btTransform identityTransform(btMatrix3x3::getIdentity()); + return identityTransform; } private: