From a3f1417abd195ffd5a85504c853db1a90cb755da Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 3 Jun 2013 12:57:20 +0200 Subject: [PATCH] Added Matrix4::Apply[Rotation|Translation] Former-commit-id: 1c59aa48f057d4bdc4b4413e349d2b4290dec055 --- include/Nazara/Math/Matrix4.hpp | 2 ++ include/Nazara/Math/Matrix4.inl | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/Nazara/Math/Matrix4.hpp b/include/Nazara/Math/Matrix4.hpp index 89aeec65e..f1b278f94 100644 --- a/include/Nazara/Math/Matrix4.hpp +++ b/include/Nazara/Math/Matrix4.hpp @@ -31,7 +31,9 @@ class NzMatrix4 NzMatrix4(const NzMatrix4& matrix) = default; ~NzMatrix4() = default; + NzMatrix4& ApplyRotation(const NzQuaternion& rotation); NzMatrix4& ApplyScale(const NzVector3& scale); + NzMatrix4& ApplyTranslation(const NzVector3& translation); NzMatrix4& Concatenate(const NzMatrix4& matrix); NzMatrix4& ConcatenateAffine(const NzMatrix4& matrix); diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index e8a54c811..3b271681e 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -43,6 +43,12 @@ NzMatrix4::NzMatrix4(const NzMatrix4& matrix) Set(matrix); } +template +NzMatrix4& NzMatrix4::ApplyRotation(const NzQuaternion& rotation) +{ + return Concatenate(NzMatrix4f::Rotate(rotation)); +} + template NzMatrix4& NzMatrix4::ApplyScale(const NzVector3& scale) { @@ -62,6 +68,17 @@ NzMatrix4& NzMatrix4::ApplyScale(const NzVector3& scale) return *this; } +template +NzMatrix4& NzMatrix4::ApplyTranslation(const NzVector3& translation) +{ + m41 += translation.x; + m42 += translation.y; + m43 += translation.z; + m_isIdentity = false; + + return *this; +} + template NzMatrix4& NzMatrix4::Concatenate(const NzMatrix4& matrix) {