changed Vector3f

This commit is contained in:
ikpil 2023-03-28 01:01:50 +09:00
parent f6b3b43442
commit dbed85ab17
1 changed files with 43 additions and 0 deletions

View File

@ -16,6 +16,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
using System;
using System.Numerics;
namespace DotRecast.Core namespace DotRecast.Core
{ {
public struct Vector3f public struct Vector3f
@ -30,5 +33,45 @@ namespace DotRecast.Core
this.y = y; this.y = y;
this.z = z; this.z = z;
} }
public float this[int index]
{
get => GetElement(index);
set => SetElement(index, value);
}
public float GetElement(int index)
{
switch (index)
{
case 0: return x;
case 1: return y;
case 2: return z;
default: throw new IndexOutOfRangeException($"{index}");
}
}
public void SetElement(int index, float value)
{
switch (index)
{
case 0:
x = value;
break;
case 1:
y = value;
break;
case 2:
z = value;
break;
default: throw new IndexOutOfRangeException($"{index}-{value}");
}
}
public float[] ToArray()
{
return new float[] { x, y, z };
}
} }
} }