From d6f752c113406be651b9548b9a3630db7010d77d Mon Sep 17 00:00:00 2001 From: thorium-cfx <102315529+thorium-cfx@users.noreply.github.com> Date: Fri, 16 Jun 2023 11:20:44 +0200 Subject: [PATCH] fix(clrcore): adjust vector directions for Z-up Current math library is designed for a Y-up coordinate system, while GTA has a Z-up RH coordinate system. No one should've used these in their previous state. * Swap forward and up vectors * Add `Vector3.Forward` and `Vector3.Backward` so users don't need to know if they need the LH or RH version. --- code/client/clrcore/Math/Vector3.cs | 30 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/code/client/clrcore/Math/Vector3.cs b/code/client/clrcore/Math/Vector3.cs index 95556bb590..2195bac587 100644 --- a/code/client/clrcore/Math/Vector3.cs +++ b/code/client/clrcore/Math/Vector3.cs @@ -80,14 +80,14 @@ public struct Vector3 : IEquatable, IFormattable public static readonly Vector3 One = new Vector3(1.0f, 1.0f, 1.0f); /// - /// A unit designating up (0, 1, 0). + /// A unit designating up (0, 0, 1). /// - public static readonly Vector3 Up = new Vector3(0.0f, 1.0f, 0.0f); + public static readonly Vector3 Up = new Vector3(0.0f, 0.0f, 1.0f); /// - /// A unit designating down (0, -1, 0). + /// A unit designating down (0, 0, -1). /// - public static readonly Vector3 Down = new Vector3(0.0f, -1.0f, 0.0f); + public static readonly Vector3 Down = new Vector3(0.0f, 0.0f, -1.0f); /// /// A unit designating left (-1, 0, 0). @@ -100,24 +100,30 @@ public struct Vector3 : IEquatable, IFormattable public static readonly Vector3 Right = new Vector3(1.0f, 0.0f, 0.0f); /// - /// A unit designating forward in a right-handed coordinate system (0, 0, -1). + /// A unit designating forward in a right-handed coordinate system (0, 1, 0). /// - public static readonly Vector3 ForwardRH = new Vector3(0.0f, 0.0f, -1.0f); + public static readonly Vector3 ForwardRH = new Vector3(0.0f, 1.0f, 0.0f); /// - /// A unit designating forward in a left-handed coordinate system (0, 0, 1). + /// A unit designating forward in a left-handed coordinate system (0, -1, 0). /// - public static readonly Vector3 ForwardLH = new Vector3(0.0f, 0.0f, 1.0f); + public static readonly Vector3 ForwardLH = new Vector3(0.0f, -1.0f, 0.0f); /// - /// A unit designating backward in a right-handed coordinate system (0, 0, 1). + /// A unit designating backward in a right-handed coordinate system (0, -1, 0). /// - public static readonly Vector3 BackwardRH = new Vector3(0.0f, 0.0f, 1.0f); + public static readonly Vector3 BackwardRH = new Vector3(0.0f, -1.0f, 0.0f); /// - /// A unit designating backward in a left-handed coordinate system (0, 0, -1). + /// A unit designating backward in a left-handed coordinate system (0, 1, 0). /// - public static readonly Vector3 BackwardLH = new Vector3(0.0f, 0.0f, -1.0f); + public static readonly Vector3 BackwardLH = new Vector3(0.0f, 1.0f, 0.0f); + + /// + public static readonly Vector3 Forward = ForwardRH; + + /// + public static readonly Vector3 Backward = BackwardRH; /// /// The X component of the vector.