From 3da17918aacacdf16895a32231c571a55b691d53 Mon Sep 17 00:00:00 2001 From: Nejcraft Date: Sat, 20 Feb 2021 14:58:05 +0100 Subject: [PATCH] Overloaded --- Source/Engine/Core/Math/Quaternion.cs | 40 ++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/Source/Engine/Core/Math/Quaternion.cs b/Source/Engine/Core/Math/Quaternion.cs index 19eb199fe..fb763154e 100644 --- a/Source/Engine/Core/Math/Quaternion.cs +++ b/Source/Engine/Core/Math/Quaternion.cs @@ -967,7 +967,17 @@ namespace FlaxEngine Matrix3x3.LookAt(ref eye, ref target, ref up, out var matrix); RotationMatrix(ref matrix, out result); } - + + /// + /// Creates a left-handed, look-at quaternion. + /// + /// The position of the viewer's eye. + /// The camera look-at target. + /// The created look-at quaternion. + public static Quaternion LookAt(Vector3 eye, Vector3 target){ + return LookAt(eye, target, Vector3.Up); + } + /// /// Creates a left-handed, look-at quaternion. /// @@ -975,10 +985,8 @@ namespace FlaxEngine /// The camera look-at target. /// The camera's up vector. /// The created look-at quaternion. - public static Quaternion LookAt(Vector3 eye, Vector3 target, Vector3 up = null) + public static Quaternion LookAt(Vector3 eye, Vector3 target, Vector3 up) { - if(up == null) - up = Vector3.Up; LookAt(ref eye, ref target, ref up, out var result); return result; } @@ -995,20 +1003,38 @@ namespace FlaxEngine LookAt(ref eye, ref forward, ref up, out result); } + /// + /// Creates a left-handed, look-at quaternion. + /// + /// The camera's forward direction. + /// The created look-at quaternion. + public static Quaternion RotationLookAt(Vector3 forward) + { + return RotationLookAt(forward, Vector3.Up); + } + /// /// Creates a left-handed, look-at quaternion. /// /// The camera's forward direction. /// The camera's up vector. /// The created look-at quaternion. - public static Quaternion RotationLookAt(Vector3 forward, Vector3 up = null) + public static Quaternion RotationLookAt(Vector3 forward, Vector3 up) { - if(up == null) - up = Vector3.Up; RotationLookAt(ref forward, ref up, out var result); return result; } + /// + /// Creates a rotation with the specified forward and upwards directions. + /// + /// The forward direction. Direction to orient towards. + /// The calculated quaternion. + public static Quaternion LookRotation(Vector3 forward) + { + return LookRotation(forward, Vector3.Up); + } + /// /// Creates a rotation with the specified forward and upwards directions. ///