daily update on 20230830

This commit is contained in:
Nitload
2023-08-30 22:49:11 +08:00
parent 1fcbfb972b
commit c6f4b3dd53
55 changed files with 648 additions and 1198 deletions
+31 -1
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -6,7 +7,7 @@ using System.Runtime.InteropServices;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit, Size = 7*4*sizeof(float)+ sizeof(bool),Pack =16 )]
public struct Matrix4x3
public struct Matrix4x3 : IEquatable<Matrix4x3>
{
[FieldOffset(0)]
internal Mat3 mat;
@@ -97,6 +98,17 @@ namespace StgSharp.Math
}
}
public override bool Equals(object? obj)
{
return obj is Matrix4x3 x && Equals(x);
}
public bool Equals(Matrix4x3 other)
{
return EqualityComparer<Mat3>.Default.Equals(mat, other.mat);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Matrix4x3 operator +(Matrix4x3 left, Matrix4x3 right)
{
@@ -118,6 +130,16 @@ namespace StgSharp.Math
}
public static bool operator ==(Matrix4x3 left, Matrix4x3 right)
{
return left.Equals(right);
}
public static bool operator !=(Matrix4x3 left, Matrix4x3 right)
{
return !(left == right);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Matrix4x3 operator *(Matrix4x3 mat, float value)
{
@@ -210,6 +232,14 @@ namespace StgSharp.Math
);
}
public override int GetHashCode()
{
return HashCode.Combine(
mat.colum0.GetHashCode(),
mat.colum1.GetHashCode(),
mat.colum2.GetHashCode()
);
}