2023-03-28 19:52:26 +03:00
|
|
|
using System;
|
2023-06-13 08:53:51 +03:00
|
|
|
using System.Runtime.CompilerServices;
|
2023-03-28 19:52:26 +03:00
|
|
|
|
|
|
|
namespace DotRecast.Core
|
|
|
|
{
|
2023-06-03 15:47:26 +03:00
|
|
|
public struct RcVec2f
|
2023-03-28 19:52:26 +03:00
|
|
|
{
|
|
|
|
public float x;
|
|
|
|
public float y;
|
2023-04-15 03:31:51 +03:00
|
|
|
|
2023-06-03 15:47:26 +03:00
|
|
|
public static RcVec2f Zero { get; } = new RcVec2f { x = 0, y = 0 };
|
2023-04-16 06:19:41 +03:00
|
|
|
|
2023-04-15 03:31:51 +03:00
|
|
|
public float Get(int idx)
|
|
|
|
{
|
|
|
|
if (0 == idx)
|
|
|
|
return x;
|
|
|
|
|
|
|
|
if (1 == idx)
|
|
|
|
return y;
|
|
|
|
|
|
|
|
throw new IndexOutOfRangeException("vector2f index out of range");
|
|
|
|
}
|
2023-05-08 17:12:11 +03:00
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
{
|
2023-06-03 15:47:26 +03:00
|
|
|
if (!(obj is RcVec2f))
|
2023-05-08 17:12:11 +03:00
|
|
|
return false;
|
|
|
|
|
2023-06-03 15:47:26 +03:00
|
|
|
return Equals((RcVec2f)obj);
|
2023-05-08 17:12:11 +03:00
|
|
|
}
|
|
|
|
|
2023-06-13 08:53:51 +03:00
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-06-03 15:47:26 +03:00
|
|
|
public bool Equals(RcVec2f other)
|
2023-05-08 17:12:11 +03:00
|
|
|
{
|
|
|
|
return x.Equals(other.x) &&
|
|
|
|
y.Equals(other.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
{
|
|
|
|
int hash = x.GetHashCode();
|
|
|
|
hash = RcHashCodes.CombineHashCodes(hash, y.GetHashCode());
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
2023-06-13 08:53:51 +03:00
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-06-03 15:47:26 +03:00
|
|
|
public static bool operator ==(RcVec2f left, RcVec2f right)
|
2023-05-08 17:12:11 +03:00
|
|
|
{
|
|
|
|
return left.Equals(right);
|
|
|
|
}
|
|
|
|
|
2023-06-13 08:53:51 +03:00
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-06-03 15:47:26 +03:00
|
|
|
public static bool operator !=(RcVec2f left, RcVec2f right)
|
2023-05-08 17:12:11 +03:00
|
|
|
{
|
|
|
|
return !left.Equals(right);
|
|
|
|
}
|
2023-06-13 08:53:51 +03:00
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return $"{x}, {y}";
|
|
|
|
}
|
2023-03-28 19:52:26 +03:00
|
|
|
}
|
|
|
|
}
|