diff options
| author | Léo Lam <leo@leolam.fr> | 2021-01-28 01:34:09 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-28 01:34:09 +0100 |
| commit | c386c5acc2b54235ffac4b26596511d5189c73f5 (patch) | |
| tree | aa25b4bf24e698374d952aeeae62395fdd3265aa /Source/Core/Common/Matrix.cpp | |
| parent | 9ca24ae8e0da53d09e402d18055f102440af7098 (diff) | |
| parent | 586c689d63ad30f12eba0a15161ea5070989751f (diff) | |
Merge pull request #9366 from iwubcode/freelook_camera_quaternion
VideoCommon: allow Free Look to be manipulated by a quaternion
Diffstat (limited to 'Source/Core/Common/Matrix.cpp')
| -rw-r--r-- | Source/Core/Common/Matrix.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Source/Core/Common/Matrix.cpp b/Source/Core/Common/Matrix.cpp index 48adcba274..9f5ff40cb3 100644 --- a/Source/Core/Common/Matrix.cpp +++ b/Source/Core/Common/Matrix.cpp @@ -56,6 +56,13 @@ Quaternion Quaternion::RotateZ(float rad) return Rotate(rad, Vec3(0, 0, 1)); } +Quaternion Quaternion::RotateXYZ(const Vec3& rads) +{ + const auto length = rads.Length(); + return length ? Common::Quaternion::Rotate(length, rads / length) : + Common::Quaternion::Identity(); +} + Quaternion Quaternion::Rotate(float rad, const Vec3& axis) { const auto sin_angle_2 = std::sin(rad / 2); @@ -269,6 +276,11 @@ Matrix44 Matrix44::FromMatrix33(const Matrix33& m33) return mtx; } +Matrix44 Matrix44::FromQuaternion(const Quaternion& q) +{ + return FromMatrix33(Matrix33::FromQuaternion(q)); +} + Matrix44 Matrix44::FromArray(const std::array<float, 16>& arr) { Matrix44 mtx; |
