summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/FreeLookCamera.cpp
diff options
context:
space:
mode:
authoriwubcode <iwubcode@users.noreply.github.com>2021-03-12 00:02:06 -0600
committeriwubcode <iwubcode@users.noreply.github.com>2021-03-17 20:58:33 -0500
commit80cf87158ec494dd0a5c57ee37fb63b000e11194 (patch)
tree4a2eb9a6d0c26aa9aeba6367e9c6027e00b4b5b6 /Source/Core/VideoCommon/FreeLookCamera.cpp
parent80559199059bd010a2bc6ad976b400921e6754ab (diff)
VideoCommon: update FreeLook camera to add quaternion based rotation, fix orbital and fps implementations
Diffstat (limited to 'Source/Core/VideoCommon/FreeLookCamera.cpp')
-rw-r--r--Source/Core/VideoCommon/FreeLookCamera.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/Source/Core/VideoCommon/FreeLookCamera.cpp b/Source/Core/VideoCommon/FreeLookCamera.cpp
index 5526ff50f0..25eb2a7c89 100644
--- a/Source/Core/VideoCommon/FreeLookCamera.cpp
+++ b/Source/Core/VideoCommon/FreeLookCamera.cpp
@@ -102,15 +102,20 @@ public:
void Rotate(const Common::Vec3& amt) override
{
+ if (amt.Length() == 0)
+ return;
+
m_rotation += amt;
using Common::Quaternion;
- const auto quat =
+ m_rotate_quat =
(Quaternion::RotateX(m_rotation.x) * Quaternion::RotateY(m_rotation.y)).Normalized();
- Rotate(quat);
}
- void Rotate(const Common::Quaternion& quat) override { m_rotate_quat = quat; }
+ void Rotate(const Common::Quaternion& quat) override
+ {
+ Rotate(Common::FromQuaternionToEuler(quat));
+ }
void Reset() override
{
@@ -153,15 +158,20 @@ public:
void Rotate(const Common::Vec3& amt) override
{
+ if (amt.Length() == 0)
+ return;
+
m_rotation += amt;
using Common::Quaternion;
- const auto quat =
+ m_rotate_quat =
(Quaternion::RotateX(m_rotation.x) * Quaternion::RotateY(m_rotation.y)).Normalized();
- Rotate(quat);
}
- void Rotate(const Common::Quaternion& quat) override { m_rotate_quat = quat; }
+ void Rotate(const Common::Quaternion& quat) override
+ {
+ Rotate(Common::FromQuaternionToEuler(quat));
+ }
void Reset() override
{
@@ -246,6 +256,12 @@ void FreeLookCamera::Rotate(const Common::Vec3& amt)
m_dirty = true;
}
+void FreeLookCamera::Rotate(const Common::Quaternion& amt)
+{
+ m_camera_controller->Rotate(amt);
+ m_dirty = true;
+}
+
void FreeLookCamera::IncreaseFovX(float fov)
{
m_fov_x += fov;