diff options
author | Kelly Thomas <kelly.thomas@hotmail.com.au> | 2018-08-11 02:46:03 +0800 |
---|---|---|
committer | Kelly Thomas <kelly.thomas@hotmail.com.au> | 2018-08-15 02:03:36 +0800 |
commit | 815d08f10cc2b2ac7c048eb20f562119ed7f2786 (patch) | |
tree | 8ddc5421c1b076cf1f9eac63d1588622b8ca4e5b /modules/mono/glue | |
parent | d7b9fcd33689673c6237d91afdb4a8dfe548784a (diff) |
mono: add constants to transform and vector structs
Diffstat (limited to 'modules/mono/glue')
-rw-r--r-- | modules/mono/glue/cs_files/Transform.cs | 13 | ||||
-rw-r--r-- | modules/mono/glue/cs_files/Transform2D.cs | 21 | ||||
-rwxr-xr-x | modules/mono/glue/cs_files/VERSION.txt | 2 | ||||
-rw-r--r-- | modules/mono/glue/cs_files/Vector2.cs | 39 | ||||
-rw-r--r-- | modules/mono/glue/cs_files/Vector3.cs | 41 |
5 files changed, 65 insertions, 51 deletions
diff --git a/modules/mono/glue/cs_files/Transform.cs b/modules/mono/glue/cs_files/Transform.cs index d1b247a552..e432d5b52c 100644 --- a/modules/mono/glue/cs_files/Transform.cs +++ b/modules/mono/glue/cs_files/Transform.cs @@ -102,7 +102,18 @@ namespace Godot basis[0, 2] * vInv.x + basis[1, 2] * vInv.y + basis[2, 2] * vInv.z ); } - + + // Constants + private static readonly Transform _identity = new Transform(Basis.Identity, Vector3.Zero); + private static readonly Transform _flipX = new Transform(new Basis(new Vector3(-1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1)), Vector3.Zero); + private static readonly Transform _flipY = new Transform(new Basis(new Vector3(1, 0, 0), new Vector3(0, -1, 0), new Vector3(0, 0, 1)), Vector3.Zero); + private static readonly Transform _flipZ = new Transform(new Basis(new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, -1)), Vector3.Zero); + + public static Transform Identity { get { return _identity; } } + public static Transform FlipX { get { return _flipX; } } + public static Transform FlipY { get { return _flipY; } } + public static Transform FlipZ { get { return _flipZ; } } + // Constructors public Transform(Vector3 xAxis, Vector3 yAxis, Vector3 zAxis, Vector3 origin) { diff --git a/modules/mono/glue/cs_files/Transform2D.cs b/modules/mono/glue/cs_files/Transform2D.cs index ff5259178b..8d30833066 100644 --- a/modules/mono/glue/cs_files/Transform2D.cs +++ b/modules/mono/glue/cs_files/Transform2D.cs @@ -11,22 +11,10 @@ namespace Godot [StructLayout(LayoutKind.Sequential)] public struct Transform2D : IEquatable<Transform2D> { - private static readonly Transform2D identity = new Transform2D - ( - new Vector2(1f, 0f), - new Vector2(0f, 1f), - new Vector2(0f, 0f) - ); - public Vector2 x; public Vector2 y; public Vector2 o; - public static Transform2D Identity - { - get { return identity; } - } - public Vector2 Origin { get { return o; } @@ -264,6 +252,15 @@ namespace Godot Vector2 vInv = v - o; return new Vector2(x.Dot(vInv), y.Dot(vInv)); } + + // Constants + private static readonly Transform2D _identity = new Transform2D(new Vector2(1f, 0f), new Vector2(0f, 1f), Vector2.Zero); + private static readonly Transform2D _flipX = new Transform2D(new Vector2(-1f, 0f), new Vector2(0f, 1f), Vector2.Zero); + private static readonly Transform2D _flipY = new Transform2D(new Vector2(1f, 0f), new Vector2(0f, -1f), Vector2.Zero); + + public static Transform2D Identity { get { return _identity; } } + public static Transform2D FlipX { get { return _flipX; } } + public static Transform2D FlipY { get { return _flipY; } } // Constructors public Transform2D(Vector2 xAxis, Vector2 yAxis, Vector2 origin) diff --git a/modules/mono/glue/cs_files/VERSION.txt b/modules/mono/glue/cs_files/VERSION.txt index 45a4fb75db..ec635144f6 100755 --- a/modules/mono/glue/cs_files/VERSION.txt +++ b/modules/mono/glue/cs_files/VERSION.txt @@ -1 +1 @@ -8 +9 diff --git a/modules/mono/glue/cs_files/Vector2.cs b/modules/mono/glue/cs_files/Vector2.cs index c274364895..14c8de6986 100644 --- a/modules/mono/glue/cs_files/Vector2.cs +++ b/modules/mono/glue/cs_files/Vector2.cs @@ -231,24 +231,27 @@ namespace Godot { return new Vector2(y, -x); } - - private static readonly Vector2 zero = new Vector2 (0, 0); - private static readonly Vector2 one = new Vector2 (1, 1); - private static readonly Vector2 negOne = new Vector2 (-1, -1); - - private static readonly Vector2 up = new Vector2 (0, 1); - private static readonly Vector2 down = new Vector2 (0, -1); - private static readonly Vector2 right = new Vector2 (1, 0); - private static readonly Vector2 left = new Vector2 (-1, 0); - - public static Vector2 Zero { get { return zero; } } - public static Vector2 One { get { return one; } } - public static Vector2 NegOne { get { return negOne; } } - - public static Vector2 Up { get { return up; } } - public static Vector2 Down { get { return down; } } - public static Vector2 Right { get { return right; } } - public static Vector2 Left { get { return left; } } + + // Constants + private static readonly Vector2 _zero = new Vector2(0, 0); + private static readonly Vector2 _one = new Vector2(1, 1); + private static readonly Vector2 _negOne = new Vector2(-1, -1); + private static readonly Vector2 _inf = new Vector2(Mathf.Inf, Mathf.Inf); + + private static readonly Vector2 _up = new Vector2(0, -1); + private static readonly Vector2 _down = new Vector2(0, 1); + private static readonly Vector2 _right = new Vector2(1, 0); + private static readonly Vector2 _left = new Vector2(-1, 0); + + public static Vector2 Zero { get { return _zero; } } + public static Vector2 NegOne { get { return _negOne; } } + public static Vector2 One { get { return _one; } } + public static Vector2 Inf { get { return _inf; } } + + public static Vector2 Up { get { return _up; } } + public static Vector2 Down { get { return _down; } } + public static Vector2 Right { get { return _right; } } + public static Vector2 Left { get { return _left; } } // Constructors public Vector2(real_t x, real_t y) diff --git a/modules/mono/glue/cs_files/Vector3.cs b/modules/mono/glue/cs_files/Vector3.cs index 085a4f0043..861d9c54d9 100644 --- a/modules/mono/glue/cs_files/Vector3.cs +++ b/modules/mono/glue/cs_files/Vector3.cs @@ -272,27 +272,30 @@ namespace Godot ); } - private static readonly Vector3 zero = new Vector3 (0, 0, 0); - private static readonly Vector3 one = new Vector3 (1, 1, 1); - private static readonly Vector3 negOne = new Vector3 (-1, -1, -1); + // Constants + private static readonly Vector3 _zero = new Vector3(0, 0, 0); + private static readonly Vector3 _one = new Vector3(1, 1, 1); + private static readonly Vector3 _negOne = new Vector3(-1, -1, -1); + private static readonly Vector3 _inf = new Vector3(Mathf.Inf, Mathf.Inf, Mathf.Inf); - private static readonly Vector3 up = new Vector3 (0, 1, 0); - private static readonly Vector3 down = new Vector3 (0, -1, 0); - private static readonly Vector3 right = new Vector3 (1, 0, 0); - private static readonly Vector3 left = new Vector3 (-1, 0, 0); - private static readonly Vector3 forward = new Vector3 (0, 0, -1); - private static readonly Vector3 back = new Vector3 (0, 0, 1); - - public static Vector3 Zero { get { return zero; } } - public static Vector3 One { get { return one; } } - public static Vector3 NegOne { get { return negOne; } } + private static readonly Vector3 _up = new Vector3(0, 1, 0); + private static readonly Vector3 _down = new Vector3(0, -1, 0); + private static readonly Vector3 _right = new Vector3(1, 0, 0); + private static readonly Vector3 _left = new Vector3(-1, 0, 0); + private static readonly Vector3 _forward = new Vector3(0, 0, -1); + private static readonly Vector3 _back = new Vector3(0, 0, 1); + + public static Vector3 Zero { get { return _zero; } } + public static Vector3 One { get { return _one; } } + public static Vector3 NegOne { get { return _negOne; } } + public static Vector3 Inf { get { return _inf; } } - public static Vector3 Up { get { return up; } } - public static Vector3 Down { get { return down; } } - public static Vector3 Right { get { return right; } } - public static Vector3 Left { get { return left; } } - public static Vector3 Forward { get { return forward; } } - public static Vector3 Back { get { return back; } } + public static Vector3 Up { get { return _up; } } + public static Vector3 Down { get { return _down; } } + public static Vector3 Right { get { return _right; } } + public static Vector3 Left { get { return _left; } } + public static Vector3 Forward { get { return _forward; } } + public static Vector3 Back { get { return _back; } } // Constructors public Vector3(real_t x, real_t y, real_t z) |