daily update on 20230822 by nitload youmu
This commit is contained in:
@@ -5,139 +5,7 @@ namespace StgSharp.Math
|
||||
{
|
||||
public class Matrix4x3
|
||||
{
|
||||
internal M128Map map;
|
||||
|
||||
internal IntPtr _colum0Ptr = IntPtr.Zero;
|
||||
internal IntPtr _colum1Ptr;
|
||||
internal IntPtr _colum2Ptr;
|
||||
|
||||
private bool _isTransposed;
|
||||
private Matrix3x4 _transpose;
|
||||
|
||||
public Matrix4x3(
|
||||
float a00, float a01, float a02,
|
||||
float a10, float a11, float a12,
|
||||
float a20, float a21, float a22,
|
||||
float a30, float a31, float a32
|
||||
)
|
||||
{
|
||||
_colum0Ptr = internalIO.load_internal(a00,a10,a20,a30);
|
||||
_colum1Ptr = internalIO.load_internal(a01,a11,a21,a31);
|
||||
_colum2Ptr = internalIO.load_internal(a02,a12,a22,a32);
|
||||
|
||||
_transpose = new Matrix3x4(this);
|
||||
}
|
||||
|
||||
internal Matrix4x3(
|
||||
IntPtr colum0Ptr,
|
||||
IntPtr colum1Ptr,
|
||||
IntPtr colum2Ptr
|
||||
)
|
||||
{
|
||||
_colum0Ptr = colum0Ptr;
|
||||
_colum1Ptr = colum1Ptr;
|
||||
_colum2Ptr = colum2Ptr;
|
||||
|
||||
_transpose = new Matrix3x4(this);
|
||||
}
|
||||
|
||||
internal Matrix4x3(Matrix3x4 transpose)
|
||||
{
|
||||
this._transpose = transpose;
|
||||
}
|
||||
|
||||
|
||||
public unsafe Matrix3x4 Transpose(TransposeMode transposeMode)
|
||||
{
|
||||
if (!_isTransposed)
|
||||
{
|
||||
(*(M128*)_transpose._colum0Ptr).single_0 = (*(M128*)_colum0Ptr).single_0;
|
||||
(*(M128*)_transpose._colum0Ptr).single_1 = (*(M128*)_colum1Ptr).single_0;
|
||||
(*(M128*)_transpose._colum0Ptr).single_2 = (*(M128*)_colum2Ptr).single_0;
|
||||
|
||||
(*(M128*)_transpose._colum1Ptr).single_0 = (*(M128*)_colum0Ptr).single_1;
|
||||
(*(M128*)_transpose._colum1Ptr).single_1 = (*(M128*)_colum1Ptr).single_1;
|
||||
(*(M128*)_transpose._colum1Ptr).single_2 = (*(M128*)_colum2Ptr).single_1;
|
||||
|
||||
(*(M128*)_transpose._colum2Ptr).single_0 = (*(M128*)_colum0Ptr).single_2;
|
||||
(*(M128*)_transpose._colum2Ptr).single_1 = (*(M128*)_colum1Ptr).single_2;
|
||||
(*(M128*)_transpose._colum2Ptr).single_2 = (*(M128*)_colum2Ptr).single_2;
|
||||
|
||||
(*(M128*)_transpose._colum3Ptr).single_0 = (*(M128*)_colum0Ptr).single_3;
|
||||
(*(M128*)_transpose._colum3Ptr).single_1 = (*(M128*)_colum1Ptr).single_3;
|
||||
(*(M128*)_transpose._colum3Ptr).single_2 = (*(M128*)_colum2Ptr).single_3;
|
||||
|
||||
_isTransposed = true;
|
||||
}
|
||||
switch (transposeMode)
|
||||
{
|
||||
case TransposeMode.New:
|
||||
return new Matrix3x4(
|
||||
_transpose._colum0Ptr,
|
||||
_transpose._colum1Ptr,
|
||||
_transpose._colum2Ptr,
|
||||
_transpose._colum3Ptr
|
||||
);
|
||||
break;
|
||||
case TransposeMode.Copy:
|
||||
return _transpose;
|
||||
break;
|
||||
default:
|
||||
throw new Exception();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static Matrix4x3 operator +(Matrix4x3 matrix1, Matrix4x3 matrix2)
|
||||
{
|
||||
return new Matrix4x3(
|
||||
internalIO.addps_internal(matrix1._colum0Ptr, matrix2._colum0Ptr),
|
||||
internalIO.addps_internal(matrix1._colum1Ptr, matrix2._colum1Ptr),
|
||||
internalIO.addps_internal(matrix1._colum2Ptr, matrix2._colum2Ptr)
|
||||
);
|
||||
}
|
||||
|
||||
public static Matrix4x3 operator -(Matrix4x3 matrix1, Matrix4x3 matrix2)
|
||||
{
|
||||
return new Matrix4x3(
|
||||
internalIO.subps_internal(matrix1._colum0Ptr, matrix2._colum0Ptr),
|
||||
internalIO.subps_internal(matrix1._colum1Ptr, matrix2._colum1Ptr),
|
||||
internalIO.subps_internal(matrix1._colum2Ptr, matrix2._colum2Ptr)
|
||||
) ;
|
||||
}
|
||||
|
||||
public static Matrix4x3 operator *(Matrix4x3 matrix, float value)
|
||||
{
|
||||
return new Matrix4x3(
|
||||
internalIO.mulps_const_internal(matrix._colum0Ptr,value),
|
||||
internalIO.mulps_const_internal(matrix._colum1Ptr,value),
|
||||
internalIO.mulps_const_internal(matrix._colum2Ptr,value)
|
||||
);
|
||||
}
|
||||
|
||||
public static Matrix4x3 operator /(Matrix4x3 matrix, float value)
|
||||
{
|
||||
return new Matrix4x3(
|
||||
internalIO.divps_const_internal(matrix._colum0Ptr,value),
|
||||
internalIO.divps_const_internal(matrix._colum1Ptr,value),
|
||||
internalIO.divps_const_internal(matrix._colum2Ptr,value)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
~Matrix4x3()
|
||||
{
|
||||
if (map == null)
|
||||
{
|
||||
internalIO.deinitM128_internal(_colum0Ptr);
|
||||
internalIO.deinitM128_internal(_colum1Ptr);
|
||||
internalIO.deinitM128_internal(_colum2Ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user