From b0f418c481af8ce20ddde19a429413e7605052de Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 26 May 2015 23:38:06 +0200 Subject: [PATCH] Math/Matrix4: Add GetSquaredScale() method Former-commit-id: c1ce74560b735dbcd5a4c377a7577a9d2c1bae09 --- include/Nazara/Math/Matrix4.hpp | 1 + include/Nazara/Math/Matrix4.inl | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Math/Matrix4.hpp b/include/Nazara/Math/Matrix4.hpp index ac142f4f1..3e97846b6 100644 --- a/include/Nazara/Math/Matrix4.hpp +++ b/include/Nazara/Math/Matrix4.hpp @@ -49,6 +49,7 @@ class NzMatrix4 //NzMatrix3 GetRotationMatrix() const; NzVector4 GetRow(unsigned int row) const; NzVector3 GetScale() const; + NzVector3 GetSquaredScale() const; NzVector3 GetTranslation() const; void GetTransposed(NzMatrix4* dest) const; diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index e3d172c32..694ef446a 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -485,9 +485,16 @@ NzVector4 NzMatrix4::GetRow(unsigned int row) const template NzVector3 NzMatrix4::GetScale() const { - return NzVector3(std::sqrt(m11*m11 + m21*m21 + m31*m31), - std::sqrt(m12*m12 + m22*m22 + m32*m32), - std::sqrt(m13*m13 + m23*m23 + m33*m33)); + NzVector3 squaredScale = GetSquaredScale(); + return NzVector3(std::sqrt(squaredScale.x), std::sqrt(squaredScale.y), std::sqrt(squaredScale.z)); +} + +template +NzVector3 NzMatrix4::GetSquaredScale() const +{ + return NzVector3(m11*m11 + m21*m21 + m31*m31, + m12*m12 + m22*m22 + m32*m32, + m13*m13 + m23*m23 + m33*m33); } template