diff options
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/Matrix.h | 5 | ||||
-rw-r--r-- | src/math/Quaternion.h | 1 | ||||
-rw-r--r-- | src/math/math.cpp | 17 |
3 files changed, 23 insertions, 0 deletions
diff --git a/src/math/Matrix.h b/src/math/Matrix.h index b7e055c5..d8920a65 100644 --- a/src/math/Matrix.h +++ b/src/math/Matrix.h @@ -30,7 +30,11 @@ public: RwMatrixDestroy(m_attachment); } void Attach(RwMatrix *matrix, bool owner = false){ +#ifdef FIX_BUGS + if(m_attachment && m_hasRwMatrix) +#else if(m_hasRwMatrix && m_attachment) +#endif RwMatrixDestroy(m_attachment); m_attachment = matrix; m_hasRwMatrix = owner; @@ -223,6 +227,7 @@ public: void SetRotate(float xAngle, float yAngle, float zAngle); void Rotate(float x, float y, float z); void RotateX(float x); + void RotateY(float y); void RotateZ(float z); void Reorthogonalise(void); diff --git a/src/math/Quaternion.h b/src/math/Quaternion.h index 1d04bdff..dac49362 100644 --- a/src/math/Quaternion.h +++ b/src/math/Quaternion.h @@ -60,6 +60,7 @@ public: } void Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, float invSin, float t); + void Set(RwV3d *axis, float angle); void Get(RwMatrix *matrix); }; diff --git a/src/math/math.cpp b/src/math/math.cpp index eeb9d3fa..0cfc2ce9 100644 --- a/src/math/math.cpp +++ b/src/math/math.cpp @@ -60,6 +60,12 @@ CMatrix::RotateX(float x) } void +CMatrix::RotateY(float y) +{ + Rotate(0.0f, y, 0.0f); +} + +void CMatrix::RotateZ(float z) { Rotate(0.0f, 0.0f, z); @@ -178,6 +184,17 @@ CQuaternion::Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, fl } void +CQuaternion::Set(RwV3d *axis, float angle) +{ + float halfCos = Cos(angle*0.5f); + float halfSin = Sin(angle*0.5f); + x = axis->x*halfSin; + y = axis->y*halfSin; + z = axis->z*halfSin; + w = halfCos; +} + +void CQuaternion::Get(RwMatrix *matrix) { float x2 = x+x; |