daily update on 20230807 by nitload youmu

This commit is contained in:
Nitload
2023-08-07 22:12:37 +08:00
parent 0601a6dcce
commit f9f339405e
16 changed files with 573 additions and 355 deletions
+32 -57
View File
@@ -3,93 +3,68 @@ using System.Runtime.InteropServices;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct vec2d : IEquatable<vec2d>
public class Vec2d
{
[FieldOffset(0)]
public float X;
[FieldOffset(sizeof(float))]
public float Y;
public vec2d(float x, float y)
internal M128Map _map;
internal IntPtr _m128Ptr;
public unsafe float X
{
X = x;
Y = y;
get { return (*(M128*)_m128Ptr).single_0; }
set { (*(M128*)_m128Ptr).single_0 = value; }
}
public bool Equals(vec2d other)
public unsafe float Y
{
if (this.GetHashCode() != other.GetHashCode())
{
return false;
}
else
{
return this.X == other.X && this.Y == other.Y;
}
get { return (*(M128*)_m128Ptr).single_1; }
set { (*(M128*)_m128Ptr).single_1 = value; }
}
public override bool Equals(object obj)
public Vec2d(float x, float y)
{
if (obj == null)
{
return false;
}
else if (obj.GetType() != typeof(vec2d))
{
return false;
}
else
{
return this.Equals((vec2d)obj);
}
_m128Ptr = internalIO.load_internal(x, y, 0, 0);
}
public override int GetHashCode()
internal Vec2d(IntPtr value)
{
return HashCode.Combine(X, Y);
_m128Ptr = value;
}
public override string ToString()
public static Vec2d operator +(Vec2d vec1, Vec2d vec2)
{
return $"{this.X}\t{this.Y}";
return new Vec2d(
internalIO.addps_internal(vec1._m128Ptr,vec2._m128Ptr)
);
}
public static bool operator ==(vec2d vec1, vec2d vec2)
public static Vec2d operator -(Vec2d vec1, Vec2d vec2)
{
return vec1.X == vec2.X && vec1.Y == vec2.Y;
return new Vec2d(
internalIO.subps_internal(vec1._m128Ptr,vec2._m128Ptr)
);
}
public static bool operator !=(vec2d vec1, vec2d vec2)
public static Vec2d operator *(Vec2d vec, float value)
{
return !(vec1.X == vec2.X && vec1.Y == vec2.Y);
return new Vec2d(
internalIO.mulps_const_internal(vec._m128Ptr,value)
);
}
public static vec2d operator +(vec2d vec1, vec2d vec2)
public static Vec2d operator /(Vec2d vec, float value)
{
return new vec2d(vec1.X + vec2.X, vec1.Y + vec2.Y);
return new Vec2d(
internalIO.divps_const_internal(vec._m128Ptr, value)
);
}
public static vec2d operator -(vec2d vec1, vec2d vec2)
public static float operator *(Vec2d vec1, Vec2d vec2)
{
return new vec2d(vec1.X - vec2.X, vec1.Y - vec2.Y);
return internalIO.mulps_sum_internal(vec1._m128Ptr, vec2._m128Ptr);
}
public static vec2d operator *(vec2d vec, float x)
{
return new vec2d(vec.X * x, vec.Y * x);
}
public static vec2d operator /(vec2d vec, float x)
{
return new vec2d(vec.X / x, vec.Y / x);
}
public static implicit operator float[](vec2d vec)
{
return new float[2] { vec.X, vec.Y };
}
}
}