Daily update on 20250618-051714 by Nitload Youmu. Additional Message : Brief support to collection operation in EXPRESS. A collection type added in core lib and compilestack.
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -40,27 +40,9 @@ namespace StgSharp.Math
|
||||
public interface IVector<TSelf> where TSelf: struct, IVector<TSelf>
|
||||
{
|
||||
|
||||
public static abstract TSelf Zero
|
||||
{
|
||||
get;
|
||||
}
|
||||
public static abstract TSelf Zero { get; }
|
||||
|
||||
public static abstract TSelf One
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public Vec2 XY
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Vec3 XYZ
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static abstract TSelf One { get; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,8 @@ namespace StgSharp.Math
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
internal void InternalTranspose()
|
||||
{
|
||||
if( !isTransposed ) {
|
||||
if( !isTransposed )
|
||||
{
|
||||
_transpose = _mat;
|
||||
float cache = _transpose.m10;
|
||||
_transpose.m10 = _transpose.m01;
|
||||
@@ -106,21 +107,17 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix22 operator -(
|
||||
Matrix22 left,
|
||||
Matrix22 right )
|
||||
public static unsafe Matrix22 operator -( Matrix22 left, Matrix22 right )
|
||||
{
|
||||
Matrix22 ret = new Matrix22();
|
||||
InternalIO.Intrinsic.sub_mat_2( &left._mat, &right._mat,
|
||||
&ret._mat );
|
||||
InternalIO.Intrinsic.sub_mat_2( &left._mat, &right._mat, &ret._mat );
|
||||
return ret;
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Matrix22 operator *( Matrix22 mat, float value )
|
||||
{
|
||||
return new Matrix22(
|
||||
mat._mat.colum0 * value, mat._mat.colum1 * value );
|
||||
return new Matrix22( mat._mat.colum0 * value, mat._mat.colum1 * value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
@@ -168,18 +165,14 @@ namespace StgSharp.Math
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Matrix22 operator /( Matrix22 mat, float value )
|
||||
{
|
||||
return new Matrix22(
|
||||
mat._mat.colum0 / value, mat._mat.colum1 / value );
|
||||
return new Matrix22( mat._mat.colum0 / value, mat._mat.colum1 / value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix22 operator +(
|
||||
Matrix22 left,
|
||||
Matrix22 right )
|
||||
public static unsafe Matrix22 operator +( Matrix22 left, Matrix22 right )
|
||||
{
|
||||
Matrix22 ret = new Matrix22();
|
||||
InternalIO.Intrinsic.add_mat_2( &left._mat, &right._mat,
|
||||
&ret._mat );
|
||||
InternalIO.Intrinsic.add_mat_2( &left._mat, &right._mat, &ret._mat );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,13 +61,7 @@ namespace StgSharp.Math
|
||||
Unsafe.SkipInit( out _transpose );
|
||||
}
|
||||
|
||||
public Matrix23(
|
||||
float a00,
|
||||
float a01,
|
||||
float a02,
|
||||
float a10,
|
||||
float a11,
|
||||
float a12 )
|
||||
public Matrix23( float a00, float a01, float a02, float a10, float a11, float a12 )
|
||||
{
|
||||
_mat.colum0 = new Vector4( a00, a10, 0, 0 );
|
||||
_mat.colum1 = new Vector4( a01, a11, 0, 0 );
|
||||
@@ -85,7 +79,8 @@ namespace StgSharp.Math
|
||||
throw new ArgumentOutOfRangeException( nameof( columNum ) );
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this._transpose.m00 ) {
|
||||
fixed( float* p = &this._transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
return *( float* )pbit;
|
||||
}
|
||||
@@ -99,7 +94,8 @@ namespace StgSharp.Math
|
||||
throw new ArgumentOutOfRangeException( nameof( columNum ) );
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this._transpose.m00 ) {
|
||||
fixed( float* p = &this._transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
*( float* )pbit = value;
|
||||
}
|
||||
@@ -110,8 +106,10 @@ namespace StgSharp.Math
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if( !isTransposed ) {
|
||||
fixed( ColumnSet3* source = &this._mat ) {
|
||||
if( !isTransposed )
|
||||
{
|
||||
fixed( ColumnSet3* source = &this._mat )
|
||||
{
|
||||
fixed( ColumnSet2* target = &this._transpose ) {
|
||||
InternalIO.Intrinsic.transpose32( source, target );
|
||||
}
|
||||
@@ -122,13 +120,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix23 operator -(
|
||||
Matrix23 left,
|
||||
Matrix23 right )
|
||||
public static unsafe Matrix23 operator -( Matrix23 left, Matrix23 right )
|
||||
{
|
||||
Matrix23 ret = new Matrix23();
|
||||
InternalIO.Intrinsic.sub_mat_3( &left._mat, &right._mat,
|
||||
&ret._mat );
|
||||
InternalIO.Intrinsic.sub_mat_3( &left._mat, &right._mat, &ret._mat );
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -136,8 +131,7 @@ namespace StgSharp.Math
|
||||
public static Matrix23 operator *( Matrix23 mat, float value )
|
||||
{
|
||||
return new Matrix23(
|
||||
mat._mat.colum0 * value, mat._mat.colum1 * value,
|
||||
mat._mat.colum2 * value );
|
||||
mat._mat.colum0 * value, mat._mat.colum1 * value, mat._mat.colum2 * value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
@@ -186,18 +180,14 @@ namespace StgSharp.Math
|
||||
public static Matrix23 operator /( Matrix23 mat, float value )
|
||||
{
|
||||
return new Matrix23(
|
||||
mat._mat.colum0 / value, mat._mat.colum1 / value,
|
||||
mat._mat.colum2 / value );
|
||||
mat._mat.colum0 / value, mat._mat.colum1 / value, mat._mat.colum2 / value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix23 operator +(
|
||||
Matrix23 left,
|
||||
Matrix23 right )
|
||||
public static unsafe Matrix23 operator +( Matrix23 left, Matrix23 right )
|
||||
{
|
||||
Matrix23 ret = new Matrix23();
|
||||
InternalIO.Intrinsic.add_mat_3( &left._mat, &right._mat,
|
||||
&ret._mat );
|
||||
InternalIO.Intrinsic.add_mat_3( &left._mat, &right._mat, &ret._mat );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Matrix24.cs"
|
||||
// Project: StgSharp
|
||||
// Project: World
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
|
||||
@@ -66,13 +66,7 @@ namespace StgSharp.Math
|
||||
isTransposed = false;
|
||||
}
|
||||
|
||||
public unsafe Matrix32(
|
||||
float a00,
|
||||
float a01,
|
||||
float a10,
|
||||
float a11,
|
||||
float a20,
|
||||
float a21 )
|
||||
public unsafe Matrix32( float a00, float a01, float a10, float a11, float a20, float a21 )
|
||||
{
|
||||
Unsafe.SkipInit( out this );
|
||||
isTransposed = false;
|
||||
@@ -91,7 +85,8 @@ namespace StgSharp.Math
|
||||
throw new ArgumentOutOfRangeException( nameof( columNum ) );
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this.transpose.m00 ) {
|
||||
fixed( float* p = &this.transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
return *( float* )pbit;
|
||||
}
|
||||
@@ -105,7 +100,8 @@ namespace StgSharp.Math
|
||||
throw new ArgumentOutOfRangeException( nameof( columNum ) );
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this.transpose.m00 ) {
|
||||
fixed( float* p = &this.transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
*( float* )pbit = value;
|
||||
}
|
||||
@@ -121,8 +117,10 @@ namespace StgSharp.Math
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if( !isTransposed ) {
|
||||
fixed( ColumnSet2* source = &this.mat ) {
|
||||
if( !isTransposed )
|
||||
{
|
||||
fixed( ColumnSet2* source = &this.mat )
|
||||
{
|
||||
fixed( ColumnSet3* target = &this.transpose ) {
|
||||
InternalIO.Intrinsic.transpose23( source, target );
|
||||
}
|
||||
@@ -136,15 +134,13 @@ namespace StgSharp.Math
|
||||
public static Matrix32 operator -( Matrix32 left, Matrix32 right )
|
||||
{
|
||||
return new Matrix32(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1 );
|
||||
left.mat.colum0 - right.mat.colum0, left.mat.colum1 - right.mat.colum1 );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Matrix32 operator *( Matrix32 mat, float value )
|
||||
{
|
||||
return new Matrix32(
|
||||
mat.mat.colum0 * value, mat.mat.colum1 * value );
|
||||
return new Matrix32( mat.mat.colum0 * value, mat.mat.colum1 * value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
@@ -204,14 +200,11 @@ namespace StgSharp.Math
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Matrix32 operator /( Matrix32 mat, float value )
|
||||
{
|
||||
return new Matrix32(
|
||||
mat.mat.colum0 / value, mat.mat.colum1 / value );
|
||||
return new Matrix32( mat.mat.colum0 / value, mat.mat.colum1 / value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix32 operator +(
|
||||
Matrix32 left,
|
||||
Matrix32 right )
|
||||
public static unsafe Matrix32 operator +( Matrix32 left, Matrix32 right )
|
||||
{
|
||||
Matrix32 ret = new Matrix32();
|
||||
InternalIO.Intrinsic.add_mat_2( &left.mat, &right.mat, &ret.mat );
|
||||
|
||||
@@ -68,15 +68,15 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
public Matrix33(
|
||||
float a00,
|
||||
float a01,
|
||||
float a02,
|
||||
float a10,
|
||||
float a11,
|
||||
float a12,
|
||||
float a20,
|
||||
float a21,
|
||||
float a22 )
|
||||
float a00,
|
||||
float a01,
|
||||
float a02,
|
||||
float a10,
|
||||
float a11,
|
||||
float a12,
|
||||
float a20,
|
||||
float a21,
|
||||
float a22 )
|
||||
{
|
||||
Unsafe.SkipInit( out this );
|
||||
isTransposed = false;
|
||||
@@ -96,7 +96,8 @@ namespace StgSharp.Math
|
||||
throw new ArgumentOutOfRangeException( nameof( columNum ) );
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this.transpose.m00 ) {
|
||||
fixed( float* p = &this.transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
return *( float* )pbit;
|
||||
}
|
||||
@@ -112,7 +113,8 @@ namespace StgSharp.Math
|
||||
LogType.Error );
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this.transpose.m00 ) {
|
||||
fixed( float* p = &this.transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
*( float* )pbit = value;
|
||||
}
|
||||
@@ -131,7 +133,8 @@ namespace StgSharp.Math
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if( !isTransposed ) {
|
||||
if( !isTransposed )
|
||||
{
|
||||
fixed( ColumnSet3* source = &this.mat, target = &this.transpose ) {
|
||||
InternalIO.Intrinsic.transpose33( source, target );
|
||||
}
|
||||
@@ -140,9 +143,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix33 operator -(
|
||||
Matrix33 left,
|
||||
Matrix33 right )
|
||||
public static unsafe Matrix33 operator -( Matrix33 left, Matrix33 right )
|
||||
{
|
||||
Matrix33 ret = new Matrix33();
|
||||
InternalIO.Intrinsic.sub_mat_3( &left.mat, &right.mat, &ret.mat );
|
||||
@@ -153,8 +154,7 @@ namespace StgSharp.Math
|
||||
public static Matrix33 operator *( Matrix33 mat, float value )
|
||||
{
|
||||
return new Matrix33(
|
||||
mat.mat.colum0 * value, mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value );
|
||||
mat.mat.colum0 * value, mat.mat.colum1 * value, mat.mat.colum2 * value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
@@ -225,14 +225,11 @@ namespace StgSharp.Math
|
||||
public static Matrix33 operator /( Matrix33 mat, float value )
|
||||
{
|
||||
return new Matrix33(
|
||||
mat.mat.colum0 / value, mat.mat.colum1 / value,
|
||||
mat.mat.colum2 / value );
|
||||
mat.mat.colum0 / value, mat.mat.colum1 / value, mat.mat.colum2 / value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix33 operator +(
|
||||
Matrix33 left,
|
||||
Matrix33 right )
|
||||
public static unsafe Matrix33 operator +( Matrix33 left, Matrix33 right )
|
||||
{
|
||||
Matrix33 ret = new Matrix33();
|
||||
InternalIO.Intrinsic.add_mat_3( &left.mat, &right.mat, &ret.mat );
|
||||
|
||||
@@ -79,18 +79,18 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
public Matrix34(
|
||||
float a00,
|
||||
float a01,
|
||||
float a02,
|
||||
float a03,
|
||||
float a10,
|
||||
float a11,
|
||||
float a12,
|
||||
float a13,
|
||||
float a20,
|
||||
float a21,
|
||||
float a22,
|
||||
float a23 )
|
||||
float a00,
|
||||
float a01,
|
||||
float a02,
|
||||
float a03,
|
||||
float a10,
|
||||
float a11,
|
||||
float a12,
|
||||
float a13,
|
||||
float a20,
|
||||
float a21,
|
||||
float a22,
|
||||
float a23 )
|
||||
{
|
||||
Unsafe.SkipInit( out this );
|
||||
isTransposed = false;
|
||||
@@ -111,7 +111,8 @@ namespace StgSharp.Math
|
||||
throw new ArgumentOutOfRangeException( nameof( columNum ) );
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this.transpose.m00 ) {
|
||||
fixed( float* p = &this.transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
return *( float* )pbit;
|
||||
}
|
||||
@@ -125,7 +126,8 @@ namespace StgSharp.Math
|
||||
throw new ArgumentOutOfRangeException( nameof( columNum ) );
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this.transpose.m00 ) {
|
||||
fixed( float* p = &this.transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
*( float* )pbit = value;
|
||||
}
|
||||
@@ -135,8 +137,10 @@ namespace StgSharp.Math
|
||||
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if( !isTransposed ) {
|
||||
fixed( ColumnSet4* source = &this.mat ) {
|
||||
if( !isTransposed )
|
||||
{
|
||||
fixed( ColumnSet4* source = &this.mat )
|
||||
{
|
||||
fixed( ColumnSet3* target = &this.transpose ) {
|
||||
InternalIO.Intrinsic.transpose43( source, target );
|
||||
}
|
||||
@@ -147,9 +151,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix34 operator -(
|
||||
Matrix34 left,
|
||||
Matrix34 right )
|
||||
public static unsafe Matrix34 operator -( Matrix34 left, Matrix34 right )
|
||||
{
|
||||
Matrix34 ret = new Matrix34();
|
||||
InternalIO.Intrinsic.sub_mat_4( &left.mat, &right.mat, &ret.mat );
|
||||
@@ -160,8 +162,8 @@ namespace StgSharp.Math
|
||||
public static Matrix34 operator *( Matrix34 mat, float value )
|
||||
{
|
||||
return new Matrix34(
|
||||
mat.mat.colum0 * value, mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value, mat.mat.colum3 * value );
|
||||
mat.mat.colum0 * value, mat.mat.colum1 * value, mat.mat.colum2 * value,
|
||||
mat.mat.colum3 * value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
@@ -222,14 +224,12 @@ namespace StgSharp.Math
|
||||
public static Matrix34 operator /( Matrix34 mat, float value )
|
||||
{
|
||||
return new Matrix34(
|
||||
mat.mat.colum0 / value, mat.mat.colum1 / value,
|
||||
mat.mat.colum2 / value, mat.mat.colum3 / value );
|
||||
mat.mat.colum0 / value, mat.mat.colum1 / value, mat.mat.colum2 / value,
|
||||
mat.mat.colum3 / value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix34 operator +(
|
||||
Matrix34 left,
|
||||
Matrix34 right )
|
||||
public static unsafe Matrix34 operator +( Matrix34 left, Matrix34 right )
|
||||
{
|
||||
Matrix34 ret = new Matrix34();
|
||||
InternalIO.Intrinsic.add_mat_4( &left.mat, &right.mat, &ret.mat );
|
||||
|
||||
@@ -71,14 +71,14 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
public Matrix42(
|
||||
float a00,
|
||||
float a01,
|
||||
float a10,
|
||||
float a11,
|
||||
float a20,
|
||||
float a21,
|
||||
float a30,
|
||||
float a31 )
|
||||
float a00,
|
||||
float a01,
|
||||
float a10,
|
||||
float a11,
|
||||
float a20,
|
||||
float a21,
|
||||
float a30,
|
||||
float a31 )
|
||||
{
|
||||
Unsafe.SkipInit( out this );
|
||||
isTransposed = false;
|
||||
@@ -97,7 +97,8 @@ namespace StgSharp.Math
|
||||
throw new ArgumentOutOfRangeException( nameof( columNum ) );
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this.transpose.m00 ) {
|
||||
fixed( float* p = &this.transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
return *( float* )pbit;
|
||||
}
|
||||
@@ -111,7 +112,8 @@ namespace StgSharp.Math
|
||||
throw new ArgumentOutOfRangeException( nameof( columNum ) );
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this.transpose.m00 ) {
|
||||
fixed( float* p = &this.transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
*( float* )pbit = value;
|
||||
}
|
||||
@@ -121,15 +123,16 @@ namespace StgSharp.Math
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(
|
||||
mat.colum0.GetHashCode(), mat.colum1.GetHashCode() );
|
||||
return HashCode.Combine( mat.colum0.GetHashCode(), mat.colum1.GetHashCode() );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if( !isTransposed ) {
|
||||
fixed( ColumnSet2* source = &this.mat ) {
|
||||
if( !isTransposed )
|
||||
{
|
||||
fixed( ColumnSet2* source = &this.mat )
|
||||
{
|
||||
fixed( ColumnSet4* target = &this.transpose ) {
|
||||
InternalIO.Intrinsic.transpose24( source, target );
|
||||
}
|
||||
@@ -140,9 +143,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix42 operator -(
|
||||
Matrix42 left,
|
||||
Matrix42 right )
|
||||
public static unsafe Matrix42 operator -( Matrix42 left, Matrix42 right )
|
||||
{
|
||||
Matrix42 ret = new Matrix42();
|
||||
InternalIO.Intrinsic.sub_mat_2( &left.mat, &right.mat, &ret.mat );
|
||||
@@ -152,8 +153,7 @@ namespace StgSharp.Math
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Matrix42 operator *( Matrix42 mat, float value )
|
||||
{
|
||||
return new Matrix42(
|
||||
mat.mat.colum0 * value, mat.mat.colum1 * value );
|
||||
return new Matrix42( mat.mat.colum0 * value, mat.mat.colum1 * value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
@@ -225,14 +225,11 @@ namespace StgSharp.Math
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Matrix42 operator /( Matrix42 mat, float value )
|
||||
{
|
||||
return new Matrix42(
|
||||
mat.mat.colum0 / value, mat.mat.colum1 / value );
|
||||
return new Matrix42( mat.mat.colum0 / value, mat.mat.colum1 / value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix42 operator +(
|
||||
Matrix42 left,
|
||||
Matrix42 right )
|
||||
public static unsafe Matrix42 operator +( Matrix42 left, Matrix42 right )
|
||||
{
|
||||
Matrix42 ret = new Matrix42();
|
||||
InternalIO.Intrinsic.add_mat_2( &left.mat, &right.mat, &ret.mat );
|
||||
|
||||
@@ -70,18 +70,18 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
public Matrix43(
|
||||
float a00,
|
||||
float a01,
|
||||
float a02,
|
||||
float a10,
|
||||
float a11,
|
||||
float a12,
|
||||
float a20,
|
||||
float a21,
|
||||
float a22,
|
||||
float a30,
|
||||
float a31,
|
||||
float a32 )
|
||||
float a00,
|
||||
float a01,
|
||||
float a02,
|
||||
float a10,
|
||||
float a11,
|
||||
float a12,
|
||||
float a20,
|
||||
float a21,
|
||||
float a22,
|
||||
float a30,
|
||||
float a31,
|
||||
float a32 )
|
||||
{
|
||||
Unsafe.SkipInit( out this );
|
||||
isTransposed = false;
|
||||
@@ -101,7 +101,8 @@ namespace StgSharp.Math
|
||||
throw new ArgumentOutOfRangeException( nameof( columNum ) );
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this.transpose.m00 ) {
|
||||
fixed( float* p = &this.transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
return *( float* )pbit;
|
||||
}
|
||||
@@ -115,7 +116,8 @@ namespace StgSharp.Math
|
||||
throw new ArgumentOutOfRangeException( nameof( columNum ) );
|
||||
}
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this.transpose.m00 ) {
|
||||
fixed( float* p = &this.transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
*( float* )pbit = value;
|
||||
}
|
||||
@@ -130,22 +132,22 @@ namespace StgSharp.Math
|
||||
|
||||
public bool Equals( Matrix43 other )
|
||||
{
|
||||
return EqualityComparer<ColumnSet3>.Default.Equals( mat,
|
||||
other.mat );
|
||||
return EqualityComparer<ColumnSet3>.Default.Equals( mat, other.mat );
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(
|
||||
mat.colum0.GetHashCode(), mat.colum1.GetHashCode(),
|
||||
mat.colum2.GetHashCode() );
|
||||
mat.colum0.GetHashCode(), mat.colum1.GetHashCode(), mat.colum2.GetHashCode() );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if( !isTransposed ) {
|
||||
fixed( ColumnSet3* source = &this.mat ) {
|
||||
if( !isTransposed )
|
||||
{
|
||||
fixed( ColumnSet3* source = &this.mat )
|
||||
{
|
||||
fixed( ColumnSet4* target = &this.transpose ) {
|
||||
InternalIO.Intrinsic.transpose34( source, target );
|
||||
}
|
||||
@@ -159,8 +161,7 @@ namespace StgSharp.Math
|
||||
public static Matrix43 operator -( Matrix43 left, Matrix43 right )
|
||||
{
|
||||
return new Matrix43(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1,
|
||||
left.mat.colum0 - right.mat.colum0, left.mat.colum1 - right.mat.colum1,
|
||||
left.mat.colum2 - right.mat.colum2 );
|
||||
}
|
||||
|
||||
@@ -173,8 +174,7 @@ namespace StgSharp.Math
|
||||
public static unsafe Matrix43 operator *( Matrix43 mat, float value )
|
||||
{
|
||||
return new Matrix43(
|
||||
mat.mat.colum0 * value, mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value );
|
||||
mat.mat.colum0 * value, mat.mat.colum1 * value, mat.mat.colum2 * value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
@@ -247,14 +247,11 @@ namespace StgSharp.Math
|
||||
public static Matrix43 operator /( Matrix43 mat, float value )
|
||||
{
|
||||
return new Matrix43(
|
||||
mat.mat.colum0 / value, mat.mat.colum1 / value,
|
||||
mat.mat.colum2 / value );
|
||||
mat.mat.colum0 / value, mat.mat.colum1 / value, mat.mat.colum2 / value );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix43 operator +(
|
||||
Matrix43 left,
|
||||
Matrix43 right )
|
||||
public static unsafe Matrix43 operator +( Matrix43 left, Matrix43 right )
|
||||
{
|
||||
Matrix43 ret = new Matrix43();
|
||||
InternalIO.Intrinsic.add_mat_3( &left.mat, &right.mat, &ret.mat );
|
||||
|
||||
@@ -62,11 +62,7 @@ namespace StgSharp.Math
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
internal Matrix44(
|
||||
Vector4 vec0,
|
||||
Vector4 vec1,
|
||||
Vector4 vec2,
|
||||
Vector4 vec3 )
|
||||
internal Matrix44( Vector4 vec0, Vector4 vec1, Vector4 vec2, Vector4 vec3 )
|
||||
{
|
||||
Unsafe.SkipInit( out this );
|
||||
isTransposed = false;
|
||||
@@ -83,22 +79,22 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
public unsafe Matrix44(
|
||||
float a00,
|
||||
float a01,
|
||||
float a02,
|
||||
float a03,
|
||||
float a10,
|
||||
float a11,
|
||||
float a12,
|
||||
float a13,
|
||||
float a20,
|
||||
float a21,
|
||||
float a22,
|
||||
float a23,
|
||||
float a30,
|
||||
float a31,
|
||||
float a32,
|
||||
float a33 )
|
||||
float a00,
|
||||
float a01,
|
||||
float a02,
|
||||
float a03,
|
||||
float a10,
|
||||
float a11,
|
||||
float a12,
|
||||
float a13,
|
||||
float a20,
|
||||
float a21,
|
||||
float a22,
|
||||
float a23,
|
||||
float a30,
|
||||
float a31,
|
||||
float a32,
|
||||
float a33 )
|
||||
{
|
||||
Unsafe.SkipInit( out this );
|
||||
isTransposed = false;
|
||||
@@ -113,7 +109,8 @@ namespace StgSharp.Math
|
||||
get
|
||||
{
|
||||
#if DEBUG
|
||||
if( ( rowNum > 3 ) || ( rowNum < 0 ) ) {
|
||||
if( ( rowNum > 3 ) || ( rowNum < 0 ) )
|
||||
{
|
||||
throw new ArgumentOutOfRangeException( nameof( columNum ) );
|
||||
}
|
||||
if( ( columNum > 3 ) || ( columNum < 0 ) ) {
|
||||
@@ -121,7 +118,8 @@ namespace StgSharp.Math
|
||||
}
|
||||
#endif
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this.transpose.m00 ) {
|
||||
fixed( float* p = &this.transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
return *( float* )pbit;
|
||||
}
|
||||
@@ -129,7 +127,8 @@ namespace StgSharp.Math
|
||||
set
|
||||
{
|
||||
#if DEBUG
|
||||
if( ( rowNum > 3 ) || ( rowNum < 0 ) ) {
|
||||
if( ( rowNum > 3 ) || ( rowNum < 0 ) )
|
||||
{
|
||||
throw new ArgumentOutOfRangeException( nameof( columNum ) );
|
||||
}
|
||||
if( ( columNum > 3 ) || ( columNum < 0 ) ) {
|
||||
@@ -137,7 +136,8 @@ namespace StgSharp.Math
|
||||
}
|
||||
#endif
|
||||
InternalTranspose();
|
||||
fixed( float* p = &this.transpose.m00 ) {
|
||||
fixed( float* p = &this.transpose.m00 )
|
||||
{
|
||||
ulong pbit = ( ( ulong )p ) + ( ( ( ulong )sizeof( Vector4 ) ) * ( ( ulong )rowNum ) ) + ( ( ( ulong )sizeof( float ) ) * ( ( ulong )columNum ) );
|
||||
*( float* )pbit = value;
|
||||
}
|
||||
@@ -191,8 +191,8 @@ namespace StgSharp.Math
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(
|
||||
mat.colum0.GetHashCode(), mat.colum1.GetHashCode(),
|
||||
mat.colum2.GetHashCode(), mat.colum3.GetHashCode() );
|
||||
mat.colum0.GetHashCode(), mat.colum1.GetHashCode(), mat.colum2.GetHashCode(),
|
||||
mat.colum3.GetHashCode() );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
@@ -200,7 +200,8 @@ namespace StgSharp.Math
|
||||
{
|
||||
InternalTranspose();
|
||||
Matrix42 ans = new Matrix42();
|
||||
fixed( ColumnSet4* lptr = &transpose ) {
|
||||
fixed( ColumnSet4* lptr = &transpose )
|
||||
{
|
||||
fixed( Vector4* rptr = &right.mat.colum0 ) {
|
||||
InternalIO.Intrinsic.dot_42( lptr, rptr, &ans.mat.colum0 );
|
||||
}
|
||||
@@ -215,7 +216,8 @@ namespace StgSharp.Math
|
||||
|
||||
Matrix43 ans = new Matrix43();
|
||||
|
||||
fixed( Vector4* rptr = &right.mat.colum0 ) {
|
||||
fixed( Vector4* rptr = &right.mat.colum0 )
|
||||
{
|
||||
fixed( ColumnSet4* lptr = &transpose ) {
|
||||
InternalIO.Intrinsic.dot_43( lptr, rptr, &ans.mat.colum0 );
|
||||
}
|
||||
@@ -233,7 +235,8 @@ namespace StgSharp.Math
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
if( !isTransposed ) {
|
||||
if( !isTransposed )
|
||||
{
|
||||
fixed( ColumnSet4* source = &mat, target = &transpose ) {
|
||||
InternalIO.Intrinsic.transpose44( source, target );
|
||||
}
|
||||
@@ -242,15 +245,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 );
|
||||
right.mat.colum0 - left.mat.colum0, right.mat.colum1 - left.mat.colum1,
|
||||
right.mat.colum2 - left.mat.colum2, right.mat.colum3 - left.mat.colum3 );
|
||||
}
|
||||
|
||||
public static bool operator !=( Matrix44 left, Matrix44 right )
|
||||
@@ -262,17 +261,15 @@ namespace StgSharp.Math
|
||||
public static unsafe Matrix44 operator *( Matrix44 mat, float value )
|
||||
{
|
||||
return new Matrix44(
|
||||
mat.mat.colum0 * value, mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value, mat.mat.colum3 * value );
|
||||
mat.mat.colum0 * value, mat.mat.colum1 * value, mat.mat.colum2 * value,
|
||||
mat.mat.colum3 * value );
|
||||
}
|
||||
|
||||
[Obsolete(
|
||||
"The operand may cause performance loss, use Matrix.Multiple() method instead.",
|
||||
false )]
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix42 operator *(
|
||||
Matrix44 left,
|
||||
Matrix42 right )
|
||||
public static unsafe Matrix42 operator *( Matrix44 left, Matrix42 right )
|
||||
{
|
||||
return left.Multiple( right );
|
||||
}
|
||||
@@ -313,9 +310,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe Matrix44 operator +(
|
||||
Matrix44 left,
|
||||
Matrix44 right )
|
||||
public static unsafe Matrix44 operator +( Matrix44 left, Matrix44 right )
|
||||
{
|
||||
Matrix44 ret = new Matrix44();
|
||||
InternalIO.Intrinsic.add_mat_4( &left.mat, &right.mat, &ret.mat );
|
||||
|
||||
@@ -38,8 +38,8 @@ using System.Runtime.InteropServices;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
/// <summary>
|
||||
/// A two dimension vector defined by two elements. Vec2 in StgSharp are default used as colum
|
||||
/// vector.
|
||||
/// A two dimension vector defined by two elements. Vec2 in World are default used as colum
|
||||
/// vector.
|
||||
/// </summary>
|
||||
[StructLayout( LayoutKind.Explicit, Size = 16, Pack = 16 )]
|
||||
public struct Vec2 : IVector<Vec2>
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using StgSharp.HighPerformance;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
@@ -133,9 +132,11 @@ namespace StgSharp.Math
|
||||
|
||||
public override bool Equals( object obj )
|
||||
{
|
||||
if( obj is Vec3 ) {
|
||||
if( obj is Vec3 )
|
||||
{
|
||||
return this == ( Vec3 )obj;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -220,8 +221,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static unsafe implicit operator Vec3(
|
||||
(float, float, float) tuple )
|
||||
public static unsafe implicit operator Vec3( (float, float, float) tuple )
|
||||
{
|
||||
Vec3 vec = new Vec3( *( Vector3* )&tuple );
|
||||
return vec;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Vector.Cross.cs"
|
||||
// Project: StgSharp
|
||||
// Project: World
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
|
||||
@@ -43,8 +43,7 @@ namespace StgSharp.Math
|
||||
|
||||
public static float GetAngle( Vec3 vec1, Vec3 vec2 )
|
||||
{
|
||||
return Scaler.ACos(
|
||||
( vec1 * vec2 ) / ( vec1.GetLength() * vec2.GetLength() ) );
|
||||
return Scaler.ACos( ( vec1 * vec2 ) / ( vec1.GetLength() * vec2.GetLength() ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,12 +46,18 @@ namespace StgSharp.Math
|
||||
|
||||
public static Vec4 Normalize( Vec4 vec )
|
||||
{
|
||||
return new Vec4 { vec = Vector4.Normalize( vec.vec ) };
|
||||
return new Vec4
|
||||
{
|
||||
vec = Vector4.Normalize( vec.vec )
|
||||
};
|
||||
}
|
||||
|
||||
public static Vec3 Normalize( Vec3 vec )
|
||||
{
|
||||
return new Vec3 { v = Vector3.Normalize( vec.v ) };
|
||||
return new Vec3
|
||||
{
|
||||
v = Vector3.Normalize( vec.v )
|
||||
};
|
||||
}
|
||||
|
||||
public static unsafe void Normalize( ref Vec4 source, ref Vec4 target )
|
||||
@@ -76,8 +82,7 @@ namespace StgSharp.Math
|
||||
Vector3 t = target.v;
|
||||
|
||||
s = Vector3.Normalize( s );
|
||||
Vector3 projection = ( Vector3.Dot( t, s ) / Vector3.Dot( s,
|
||||
s ) ) * s;
|
||||
Vector3 projection = ( Vector3.Dot( t, s ) / Vector3.Dot( s, s ) ) * s;
|
||||
t -= projection;
|
||||
t = Vector3.Normalize( t );
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Vector.Orthogonalize.cs"
|
||||
// Project: StgSharp
|
||||
// Project: World
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -46,17 +46,21 @@ namespace StgSharp.Math
|
||||
|
||||
public static Vec4 Orthogonalize( Vec4 vec )
|
||||
{
|
||||
return new Vec4 { vec = Vector4.Normalize( vec.vec ) };
|
||||
return new Vec4
|
||||
{
|
||||
vec = Vector4.Normalize( vec.vec )
|
||||
};
|
||||
}
|
||||
|
||||
public static Vec3 Orthogonalize( Vec3 vec )
|
||||
{
|
||||
return new Vec3 { v = Vector3.Normalize( vec.v ) };
|
||||
return new Vec3
|
||||
{
|
||||
v = Vector3.Normalize( vec.v )
|
||||
};
|
||||
}
|
||||
|
||||
public static unsafe void Orthogonalize(
|
||||
ref Vec4 source,
|
||||
ref Vec4 target )
|
||||
public static unsafe void Orthogonalize( ref Vec4 source, ref Vec4 target )
|
||||
{
|
||||
Vector4 s = source.vec;
|
||||
Vector4 t = target.vec;
|
||||
@@ -73,21 +77,22 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Orthogonalize two <see cref="Vec3" />s, let their length be 1 and perpendicular to each
|
||||
/// other.
|
||||
/// Orthogonalize two <see cref="Vec3" />s, let their length be 1 and perpendicular to
|
||||
/// each other.
|
||||
/// </summary>
|
||||
/// <param _name="source"></param>
|
||||
/// <param _name="target"></param>
|
||||
public static unsafe void Orthogonalize(
|
||||
ref Vec3 source,
|
||||
ref Vec3 target )
|
||||
/// <param _label="source">
|
||||
///
|
||||
/// </param>
|
||||
/// <param _label="target">
|
||||
///
|
||||
/// </param>
|
||||
public static unsafe void Orthogonalize( ref Vec3 source, ref Vec3 target )
|
||||
{
|
||||
Vector3 s = source.v;
|
||||
Vector3 t = target.v;
|
||||
|
||||
s = Vector3.Normalize( s );
|
||||
Vector3 projection = ( Vector3.Dot( t, s ) / Vector3.Dot( s,
|
||||
s ) ) * s;
|
||||
Vector3 projection = ( Vector3.Dot( t, s ) / Vector3.Dot( s, s ) ) * s;
|
||||
t -= projection;
|
||||
t = Vector3.Normalize( t );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user