daily update on 20241226 by nitload youmu
This commit is contained in:
@@ -52,8 +52,8 @@ namespace StgSharp.Math
|
||||
|
||||
public Matrix22()
|
||||
{
|
||||
Unsafe.SkipInit( out _mat );
|
||||
Unsafe.SkipInit(out _transpose);
|
||||
Unsafe.SkipInit( out this );
|
||||
isTransposed = false;
|
||||
}
|
||||
|
||||
internal Matrix22( ColumnSet2 mat )
|
||||
@@ -63,12 +63,16 @@ namespace StgSharp.Math
|
||||
|
||||
internal Matrix22( Vector4 c0, Vector4 c1 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
_mat.colum0 = c0;
|
||||
_mat.colum1 = c1;
|
||||
}
|
||||
|
||||
public Matrix22( float a00, float a01, float a10, float a11 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
_mat.colum0 = new Vector4( a00, a10, 0, 0 );
|
||||
_mat.colum1 = new Vector4( a01, a11, 0, 0 );
|
||||
}
|
||||
@@ -163,7 +167,7 @@ namespace StgSharp.Math
|
||||
Vector4.Dot( left._transpose.colum1, right.mat.colum0 ),
|
||||
Vector4.Dot( left._transpose.colum1, right.mat.colum1 ),
|
||||
Vector4.Dot( left._transpose.colum1, right.mat.colum2 ),
|
||||
Vector4.Dot( left._transpose.colum1, right.mat.colum3 ) );
|
||||
Vector4.Dot( left._transpose.colum1, right.mat.colum3 ));
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
|
||||
@@ -43,7 +43,6 @@ namespace StgSharp.Math
|
||||
Pack = 16 )]
|
||||
public struct Matrix24 : IMat
|
||||
{
|
||||
|
||||
[FieldOffset( 6 * 4 * sizeof( float ) )] internal bool isTransposed;
|
||||
[FieldOffset( 4 * 4 * sizeof( float ) )] internal ColumnSet2 transpose;
|
||||
|
||||
@@ -54,8 +53,16 @@ namespace StgSharp.Math
|
||||
[FieldOffset( 32 )] public Vec2 Colum2;
|
||||
[FieldOffset( 48 )] public Vec2 Colum3;
|
||||
|
||||
public Matrix24()
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
}
|
||||
|
||||
internal Matrix24( Vector4 c0, Vector4 c1, Vector4 c2, Vector4 c3 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
mat.colum2 = c2;
|
||||
@@ -72,6 +79,8 @@ namespace StgSharp.Math
|
||||
float a12,
|
||||
float a13 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
mat.colum0 = new Vector4( a00, a10, 0, 0 );
|
||||
mat.colum1 = new Vector4( a01, a11, 0, 0 );
|
||||
mat.colum2 = new Vector4( a02, a12, 0, 0 );
|
||||
@@ -200,13 +209,11 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Matrix24 operator +( Matrix24 left, Matrix24 right )
|
||||
public static unsafe Matrix24 operator +( Matrix24 left, Matrix24 right )
|
||||
{
|
||||
return new Matrix24(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2,
|
||||
left.mat.colum3 + right.mat.colum3 );
|
||||
Matrix24 ret = new Matrix24();
|
||||
InternalIO.Intrinsic.add_mat_4(&left.mat,&right.mat,&ret.mat);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,8 +52,16 @@ namespace StgSharp.Math
|
||||
[FieldOffset( 0 )] internal Vec3 colum0;
|
||||
[FieldOffset( 4 * 4 )] internal Vec3 colum1;
|
||||
|
||||
public Matrix32()
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
}
|
||||
|
||||
internal Matrix32( Vector4 c0, Vector4 c1 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
}
|
||||
@@ -66,11 +74,8 @@ namespace StgSharp.Math
|
||||
float a20,
|
||||
float a21 )
|
||||
{
|
||||
#if NET5_0_OR_GREATER
|
||||
Unsafe.SkipInit( out colum0 );
|
||||
Unsafe.SkipInit( out colum1 );
|
||||
Unsafe.SkipInit( out transpose );
|
||||
#endif
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
mat.colum0 = new Vector4( a00, a10, a20, 0 );
|
||||
mat.colum1 = new Vector4( a01, a11, a21, 0 );
|
||||
}
|
||||
@@ -204,11 +209,11 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Matrix32 operator +( Matrix32 left, Matrix32 right )
|
||||
public static unsafe Matrix32 operator +( Matrix32 left, Matrix32 right )
|
||||
{
|
||||
return new Matrix32(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1 );
|
||||
Matrix32 ret = new Matrix32();
|
||||
InternalIO.Intrinsic.add_mat_2(&left.mat, &right.mat, &ret.mat);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,8 +52,16 @@ namespace StgSharp.Math
|
||||
[FieldOffset( 1 * 4 * sizeof( float ) )] public Vec3 Colum1;
|
||||
[FieldOffset( 2 * 4 * sizeof( float ) )] public Vec3 Colum2;
|
||||
|
||||
public Matrix33()
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
}
|
||||
|
||||
internal Matrix33( Vector4 c0, Vector4 c1, Vector4 c2 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
mat.colum2 = c2;
|
||||
@@ -70,6 +78,8 @@ namespace StgSharp.Math
|
||||
float a21,
|
||||
float a22 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
mat.colum0 = new Vector4( a00, a10, a20, 0 );
|
||||
mat.colum1 = new Vector4( a01, a11, a21, 0 );
|
||||
mat.colum2 = new Vector4( a02, a12, a22, 0 );
|
||||
@@ -219,12 +229,11 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Matrix33 operator +( Matrix33 left, Matrix33 right )
|
||||
public static unsafe Matrix33 operator +( Matrix33 left, Matrix33 right )
|
||||
{
|
||||
return new Matrix33(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2 );
|
||||
Matrix33 ret = new Matrix33();
|
||||
InternalIO.Intrinsic.add_mat_3(&left.mat, &right.mat, &ret.mat);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,13 +55,23 @@ namespace StgSharp.Math
|
||||
[FieldOffset( 2 * 4 * sizeof( float ) )] public Vec3 Colum2;
|
||||
[FieldOffset( 3 * 4 * sizeof( float ) )] public Vec3 Colum3;
|
||||
|
||||
public Matrix34()
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
}
|
||||
|
||||
internal Matrix34( ColumnSet4 mat )
|
||||
{
|
||||
Unsafe.SkipInit( out this );
|
||||
isTransposed = false;
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
internal Matrix34( Vector4 c0, Vector4 c1, Vector4 c2, Vector4 c3 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
mat.colum2 = c2;
|
||||
@@ -82,6 +92,8 @@ namespace StgSharp.Math
|
||||
float a22,
|
||||
float a23 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
mat.colum0 = new Vector4( a00, a10, a20, 0 );
|
||||
mat.colum0 = new Vector4( a01, a11, a21, 0 );
|
||||
mat.colum0 = new Vector4( a02, a12, a22, 0 );
|
||||
@@ -215,13 +227,12 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Matrix34 operator +( Matrix34 left, Matrix34 right )
|
||||
public static unsafe Matrix34 operator +( Matrix34 left, Matrix34 right )
|
||||
{
|
||||
return new Matrix34(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2,
|
||||
left.mat.colum3 + right.mat.colum3 );
|
||||
Matrix34 ret = new Matrix34();
|
||||
InternalIO.Intrinsic.add_mat_4(&left.mat,&right.mat,&ret.mat);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,13 +49,23 @@ namespace StgSharp.Math
|
||||
[FieldOffset( 0 )] internal ColumnSet2 mat;
|
||||
[FieldOffset( 8 * sizeof( float ) )] internal ColumnSet4 transpose;
|
||||
|
||||
public Matrix42()
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
}
|
||||
|
||||
internal Matrix42( ColumnSet2 mat )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
internal Matrix42( Vector4 c0, Vector4 c1 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed= false;
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
}
|
||||
@@ -70,6 +80,8 @@ namespace StgSharp.Math
|
||||
float a30,
|
||||
float a31 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
mat.colum0 = new Vector4( a00, a10, a20, a30 );
|
||||
mat.colum1 = new Vector4( a01, a11, a21, a31 );
|
||||
}
|
||||
|
||||
@@ -35,11 +35,12 @@ using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.AccessControl;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(
|
||||
LayoutKind.Explicit,
|
||||
layoutKind: LayoutKind.Explicit,
|
||||
Size = ( 7 * 4 * sizeof( float ) ) + sizeof( bool ),
|
||||
Pack = 16 )]
|
||||
public struct Matrix43 : IEquatable<Matrix43>, IMat
|
||||
@@ -50,12 +51,19 @@ namespace StgSharp.Math
|
||||
|
||||
[FieldOffset( 0 )]
|
||||
internal ColumnSet3 mat;
|
||||
|
||||
[FieldOffset( 3 * 4 * sizeof( float ) )]
|
||||
internal ColumnSet4 transpose;
|
||||
|
||||
public Matrix43()
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
}
|
||||
|
||||
internal Matrix43( Vector4 c0, Vector4 c1, Vector4 c2 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
mat.colum0 = c0;
|
||||
mat.colum1 = c1;
|
||||
mat.colum2 = c2;
|
||||
@@ -75,6 +83,8 @@ namespace StgSharp.Math
|
||||
float a31,
|
||||
float a32 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
mat.colum0 = new Vector4( a00, a10, a20, a30 );
|
||||
mat.colum1 = new Vector4( a01, a11, a21, a31 );
|
||||
mat.colum2 = new Vector4( a02, a12, a22, a32 );
|
||||
@@ -135,12 +145,10 @@ namespace StgSharp.Math
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if( !isTransposed ) {
|
||||
fixed( ColumnSet3* source = &this.mat ) {
|
||||
fixed( ColumnSet4* target = &this.transpose ) {
|
||||
InternalIO.Intrinsic.transpose34( source, target );
|
||||
}
|
||||
fixed( ColumnSet3* source = &this.mat )
|
||||
fixed( ColumnSet4* target = &this.transpose ) {
|
||||
InternalIO.Intrinsic.transpose34( source, target );
|
||||
}
|
||||
|
||||
isTransposed = true;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +168,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Matrix43 operator *( Matrix43 mat, float value )
|
||||
public static unsafe Matrix43 operator *( Matrix43 mat, float value )
|
||||
{
|
||||
return new Matrix43(
|
||||
mat.mat.colum0 * value, mat.mat.colum1 * value,
|
||||
@@ -242,12 +250,11 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Matrix43 operator +( Matrix43 left, Matrix43 right )
|
||||
public static unsafe Matrix43 operator +( Matrix43 left, Matrix43 right )
|
||||
{
|
||||
return new Matrix43(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2 );
|
||||
Matrix43 ret = new Matrix43();
|
||||
InternalIO.Intrinsic.add_mat_3(&left.mat, &right.mat, &ret.mat);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static bool operator ==( Matrix43 left, Matrix43 right )
|
||||
|
||||
@@ -55,8 +55,16 @@ namespace StgSharp.Math
|
||||
[FieldOffset( 8 * sizeof( float ) )] internal Vec4 colum2;
|
||||
[FieldOffset( 12 * sizeof( float ) )] internal Vec4 colum3;
|
||||
|
||||
public Matrix44()
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
}
|
||||
|
||||
internal Matrix44( ColumnSet4 mat )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
@@ -66,6 +74,8 @@ namespace StgSharp.Math
|
||||
Vector4 vec2,
|
||||
Vector4 vec3 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
mat.colum0 = vec0;
|
||||
mat.colum1 = vec1;
|
||||
mat.colum2 = vec2;
|
||||
@@ -90,6 +100,8 @@ namespace StgSharp.Math
|
||||
float a32,
|
||||
float a33 )
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
isTransposed = false;
|
||||
mat.colum0 = new Vector4( a00, a10, a20, a30 );
|
||||
mat.colum1 = new Vector4( a01, a11, a21, a31 );
|
||||
mat.colum2 = new Vector4( a02, a12, a22, a32 );
|
||||
@@ -295,15 +307,11 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix44 operator +(
|
||||
Matrix44 left,
|
||||
Matrix44 right )
|
||||
public static unsafe Matrix44 operator +(Matrix44 left, Matrix44 right )
|
||||
{
|
||||
return new Matrix44(
|
||||
right.mat.colum0 + left.mat.colum0,
|
||||
right.mat.colum1 + left.mat.colum1,
|
||||
right.mat.colum2 + left.mat.colum2,
|
||||
right.mat.colum3 + left.mat.colum3 );
|
||||
Matrix44 ret = new Matrix44();
|
||||
InternalIO.Intrinsic.add_mat_4(&left.mat, &right.mat, &ret.mat);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static bool operator ==( Matrix44 left, Matrix44 right )
|
||||
|
||||
Reference in New Issue
Block a user