Enabled vector swizzle

This commit is contained in:
Simon Lübeß
2021-12-04 15:52:48 +01:00
parent 419509ab7f
commit f28984bec5
3 changed files with 15 additions and 15 deletions
+5 -5
View File
@@ -2,7 +2,7 @@ using System;
namespace GlitchyEngine.Math namespace GlitchyEngine.Math
{ {
//[SwizzleVector(2, "Vector")] [SwizzleVector(2, "Vector")]
public struct Vector2 public struct Vector2
{ {
public const Vector2 Zero = .(0f, 0f); public const Vector2 Zero = .(0f, 0f);
@@ -10,7 +10,7 @@ namespace GlitchyEngine.Math
public const Vector2 UnitY = .(0f, 1f); public const Vector2 UnitY = .(0f, 1f);
public const Vector2 One = .(1f, 1f); public const Vector2 One = .(1f, 1f);
public const int Length = 2; public const int ComponentCount = 2;
public float X, Y; public float X, Y;
@@ -33,7 +33,7 @@ namespace GlitchyEngine.Math
[Checked] [Checked]
get mut get mut
{ {
if(index < 0 || index >= Length) if(index < 0 || index >= ComponentCount)
Internal.ThrowIndexOutOfRange(1); Internal.ThrowIndexOutOfRange(1);
return ref (&X)[index]; return ref (&X)[index];
@@ -48,7 +48,7 @@ namespace GlitchyEngine.Math
[Checked] [Checked]
get get
{ {
if(index < 0 || index >= Length) if(index < 0 || index >= ComponentCount)
Internal.ThrowIndexOutOfRange(1); Internal.ThrowIndexOutOfRange(1);
if(index == 0) if(index == 0)
@@ -69,7 +69,7 @@ namespace GlitchyEngine.Math
[Checked] [Checked]
set mut set mut
{ {
if(index < 0 || index >= Length) if(index < 0 || index >= ComponentCount)
Internal.ThrowIndexOutOfRange(1); Internal.ThrowIndexOutOfRange(1);
if(index == 0) if(index == 0)
+5 -5
View File
@@ -2,7 +2,7 @@ using System;
namespace GlitchyEngine.Math namespace GlitchyEngine.Math
{ {
//[SwizzleVector(3, "Vector")] [SwizzleVector(3, "Vector")]
public struct Vector3 public struct Vector3
{ {
public const Vector3 Zero = .(0f, 0f, 0f); public const Vector3 Zero = .(0f, 0f, 0f);
@@ -18,7 +18,7 @@ namespace GlitchyEngine.Math
public const Vector3 Up = .(0f, 1f, 0f); public const Vector3 Up = .(0f, 1f, 0f);
public const Vector3 Down = .(0f, -1f, 0f); public const Vector3 Down = .(0f, -1f, 0f);
public const int Length = 3; public const int ComponentCount = 3;
public float X, Y, Z; public float X, Y, Z;
@@ -50,7 +50,7 @@ namespace GlitchyEngine.Math
[Checked] [Checked]
get mut get mut
{ {
if(index < 0 || index >= Length) if(index < 0 || index >= ComponentCount)
Internal.ThrowIndexOutOfRange(1); Internal.ThrowIndexOutOfRange(1);
return ref (&X)[index]; return ref (&X)[index];
@@ -69,7 +69,7 @@ namespace GlitchyEngine.Math
case 0: return X; case 0: return X;
case 1: return Y; case 1: return Y;
case 2: return Z; case 2: return Z;
default: Internal.ThrowIndexOutOfRange(); default: Internal.ThrowIndexOutOfRange(1);
} }
} }
@@ -80,7 +80,7 @@ namespace GlitchyEngine.Math
case 0: X = value; case 0: X = value;
case 1: Y = value; case 1: Y = value;
case 2: Z = value; case 2: Z = value;
default: Internal.ThrowIndexOutOfRange(); default: Internal.ThrowIndexOutOfRange(1);
} }
} }
} }
+5 -5
View File
@@ -2,7 +2,7 @@ using System;
namespace GlitchyEngine.Math namespace GlitchyEngine.Math
{ {
//[SwizzleVector(4, "Vector")] [SwizzleVector(4, "Vector")]
public struct Vector4 public struct Vector4
{ {
public const Vector4 Zero = .(0f, 0f, 0f, 0f); public const Vector4 Zero = .(0f, 0f, 0f, 0f);
@@ -12,7 +12,7 @@ namespace GlitchyEngine.Math
public const Vector4 UnitW = .(0f, 0f, 0f, 1f); public const Vector4 UnitW = .(0f, 0f, 0f, 1f);
public const Vector4 One = .(1f, 1f, 1f, 1f); public const Vector4 One = .(1f, 1f, 1f, 1f);
public const int Length = 4; public const int ComponentCount = 4;
public float X, Y, Z, W; public float X, Y, Z, W;
@@ -63,7 +63,7 @@ namespace GlitchyEngine.Math
[Checked] [Checked]
get mut get mut
{ {
if(index < 0 || index >= Length) if(index < 0 || index >= ComponentCount)
Internal.ThrowIndexOutOfRange(1); Internal.ThrowIndexOutOfRange(1);
return ref (&X)[index]; return ref (&X)[index];
@@ -83,7 +83,7 @@ namespace GlitchyEngine.Math
case 1: return Y; case 1: return Y;
case 2: return Z; case 2: return Z;
case 3: return W; case 3: return W;
default: Internal.ThrowIndexOutOfRange(); default: Internal.ThrowIndexOutOfRange(1);
} }
} }
@@ -95,7 +95,7 @@ namespace GlitchyEngine.Math
case 1: Y = value; case 1: Y = value;
case 2: Z = value; case 2: Z = value;
case 3: W = value; case 3: W = value;
default: Internal.ThrowIndexOutOfRange(); default: Internal.ThrowIndexOutOfRange(1);
} }
} }
} }