mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Merge pull request #9366 from iwubcode/freelook_camera_quaternion
VideoCommon: allow Free Look to be manipulated by a quaternion
This commit is contained in:
@ -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;
|
||||
|
@ -337,6 +337,10 @@ public:
|
||||
static Quaternion RotateY(float rad);
|
||||
static Quaternion RotateZ(float rad);
|
||||
|
||||
// Returns a quaternion with rotations about each axis simulatenously (e.g processing gyroscope
|
||||
// input)
|
||||
static Quaternion RotateXYZ(const Vec3& rads);
|
||||
|
||||
static Quaternion Rotate(float rad, const Vec3& axis);
|
||||
|
||||
Quaternion() = default;
|
||||
@ -402,6 +406,7 @@ class Matrix44
|
||||
public:
|
||||
static Matrix44 Identity();
|
||||
static Matrix44 FromMatrix33(const Matrix33& m33);
|
||||
static Matrix44 FromQuaternion(const Quaternion& q);
|
||||
static Matrix44 FromArray(const std::array<float, 16>& arr);
|
||||
|
||||
static Matrix44 Translate(const Vec3& vec);
|
||||
|
Reference in New Issue
Block a user