From cfc5d55419a9d42beb42becf2393f4e38ab844bc Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Fri, 15 Apr 2016 17:23:54 -1000 Subject: [PATCH] Const correctness fixes --- include/zeus/CQuaternion.hpp | 10 ++++++---- src/CQuaternion.cpp | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/zeus/CQuaternion.hpp b/include/zeus/CQuaternion.hpp index b3fe721..4233dd1 100644 --- a/include/zeus/CQuaternion.hpp +++ b/include/zeus/CQuaternion.hpp @@ -180,11 +180,11 @@ public: CQuaternion exp() const; - float dot(const CQuaternion& quat); + float dot(const CQuaternion& quat) const; - static CQuaternion lerp(CQuaternion& a, CQuaternion& b, double t); - static CQuaternion slerp(CQuaternion& a, CQuaternion& b, double t); - static CQuaternion nlerp(CQuaternion& a, CQuaternion& b, double t); + static CQuaternion lerp(const CQuaternion& a, const CQuaternion& b, double t); + static CQuaternion slerp(const CQuaternion& a, const CQuaternion& b, double t); + static CQuaternion nlerp(const CQuaternion& a, const CQuaternion& b, double t); inline float roll() const { @@ -209,6 +209,8 @@ public: __m128 mVec128; struct { float w, x, y, z; }; }; + + static const CQuaternion skNoRotation; }; CQuaternion operator+(float lhs, const CQuaternion& rhs); diff --git a/src/CQuaternion.cpp b/src/CQuaternion.cpp index 3b1e96d..6c9635c 100644 --- a/src/CQuaternion.cpp +++ b/src/CQuaternion.cpp @@ -3,6 +3,8 @@ namespace zeus { +CQuaternion const CQuaternion::skNoRotation; + void CQuaternion::fromVector3f(const CVector3f& vec) { float cosX = std::cos(0.5f * vec.x); @@ -215,22 +217,22 @@ CQuaternion CQuaternion::exp() const return ret; } -float CQuaternion::dot(const CQuaternion& b) +float CQuaternion::dot(const CQuaternion& b) const { return x * b.x + y * b.y + z * b.z + w * b.w; } -CQuaternion CQuaternion::lerp(CQuaternion& a, CQuaternion& b, double t) +CQuaternion CQuaternion::lerp(const CQuaternion& a, const CQuaternion& b, double t) { return (a + t * (b - a)); } -CQuaternion CQuaternion::nlerp(CQuaternion& a, CQuaternion& b, double t) +CQuaternion CQuaternion::nlerp(const CQuaternion& a, const CQuaternion& b, double t) { return lerp(a, b, t).normalized(); } -CQuaternion CQuaternion::slerp(CQuaternion& a, CQuaternion& b, double t) +CQuaternion CQuaternion::slerp(const CQuaternion& a, const CQuaternion& b, double t) { if (t <= 0.0f) return a;