Fixed vector indexed access

This commit is contained in:
Simon Lübeß
2021-05-22 15:08:14 +02:00
parent b19dd60e52
commit 0f2c481616
3 changed files with 114 additions and 18 deletions
+47 -4
View File
@@ -29,6 +29,21 @@ namespace GlitchyEngine.Math
}
public ref float this[int index]
{
[Checked]
get mut
{
if(index < 0 || index >= Length)
Internal.ThrowIndexOutOfRange(1);
return ref (&X)[index];
}
[Inline]
get mut => ref (&X)[index];
}
public float this[int index]
{
[Checked]
get
@@ -36,13 +51,41 @@ namespace GlitchyEngine.Math
if(index < 0 || index >= Length)
Internal.ThrowIndexOutOfRange(1);
#unwarn
return ref (&X)[index];
if(index == 0)
return X;
else
return Y;
}
[Inline]
#unwarn
get => ref (&X)[index];
get
{
if(index == 0)
return X;
else
return Y;
}
[Checked]
set mut
{
if(index < 0 || index >= Length)
Internal.ThrowIndexOutOfRange(1);
if(index == 0)
X = value;
else
Y = value;
}
[Inline]
set mut
{
if(index == 0)
X = value;
else
Y = value;
}
}
/**