daily update on 20230822 by nitload youmu

This commit is contained in:
Nitload
2023-08-22 23:01:20 +08:00
parent 969406c4e4
commit 8aac9fee87
111 changed files with 3205 additions and 11145 deletions
+10 -116
View File
@@ -6,126 +6,20 @@ using System.Runtime.InteropServices;
namespace StgSharp.Math
{
public class Vec4d
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
public struct Vec4d
{
internal static readonly Vec4d defaultValue
= new Vec4d( 0,0,0,0 );
[FieldOffset(0)] internal M128 vec;
internal M128Map _map;
internal IntPtr _m128Ptr;
[FieldOffset(0)]public float X;
[FieldOffset(4)]public float Y;
[FieldOffset(8)]public float Z;
[FieldOffset(12)]public float W;
public unsafe float X
unsafe public Vec4d(
float x, float y, float z, float w)
{
get { return (*(M128*)_m128Ptr).single_0; }
set { (*(M128*)_m128Ptr).single_0 = value; }
X = x; Y = y; Z = z; W = w;
}
public unsafe float Y
{
get { return (*(M128*)_m128Ptr).single_1; }
set { (*(M128*)_m128Ptr).single_1 = value; }
}
public unsafe float Z
{
get { return (*(M128*)_m128Ptr).single_2; }
set { (*(M128*)_m128Ptr).single_2 = value; }
}
public unsafe float W
{
get { return (*(M128*)_m128Ptr).single_3; }
set { (*(M128*)_m128Ptr).single_3 = value; }
}
public Vec4d(float x, float y, float z, float w)
{
IntPtr a = internalIO.load_internal(x,y,z,w);
if ((ulong)a>=0)
{
this._m128Ptr = a;
}
}
/// <summary>
/// internal constructor to recive a pointer of the M128 value
/// </summary>
/// <param name="value"></param>
internal Vec4d(IntPtr value)
{
if ((long)value == -1)
{
throw new Exception("Failed to init M128 pointer!");
}
else
{
_m128Ptr = value;
}
}
public Vec4d()
{
_m128Ptr = defaultValue._m128Ptr;
}
public static unsafe Vec4d operator +(Vec4d vec1,Vec4d vec2)
{
return new Vec4d(
internalIO.addps_internal(vec1._m128Ptr,vec2._m128Ptr)
) ;
}
/**/
public static Vec4d operator -(Vec4d vec1, Vec4d vec2)
{
return new Vec4d(
internalIO.subps_internal(vec1._m128Ptr,vec2._m128Ptr)
);
}
/**/
public static Vec4d operator *(Vec4d vec, float value)
{
return new Vec4d(
internalIO.mulps_const_internal(vec._m128Ptr,value)
);
}
public static Vec4d operator /(Vec4d vec, float value)
{
return new Vec4d(
internalIO.divps_const_internal(vec._m128Ptr, value)
);
}
public unsafe override string ToString()
{
return $"{*(M128*)_m128Ptr}";
}
~Vec4d()
{
if (_map == null)
{
if (_m128Ptr != defaultValue._m128Ptr)
{
internalIO.deinitM128_internal(this._m128Ptr);
}
else
{
_m128Ptr = IntPtr.Zero;
}
}
else
{
}
}
}
}