daily update on 20240513 by nitload youmu, instancing render added

This commit is contained in:
YoumuLiu
2024-05-13 03:39:54 +08:00
parent 56459deec5
commit a3506c96a3
78 changed files with 2562 additions and 1098 deletions
+33 -34
View File
@@ -40,18 +40,18 @@ using System.Security.AccessControl;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
public struct vec3d : IEquatable<vec3d>
public struct vec3d : IEquatable<vec3d>, IVector
{
[FieldOffset(0)] internal unsafe fixed float num[3];
[FieldOffset(0)]
internal M128 reg;
[FieldOffset(0)]
internal Vector3 v;
[FieldOffset(0)]
internal Vector4 vec;
[FieldOffset(0)]
internal M128 reg;
[FieldOffset(0)] internal unsafe fixed float num[3];
[FieldOffset(0)] public float X;
[FieldOffset(4)] public float Y;
@@ -67,6 +67,12 @@ namespace StgSharp.Math
v = vector;
}
public vec3d(vec2d xy, float z)
{
vec = xy.vec;
Z = z;
}
public vec3d(
float x, float y, float z)
{
@@ -76,20 +82,16 @@ namespace StgSharp.Math
v = new Vector3(x, y, z);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public vec3d Cross(vec3d right)
public vec3d XYZ
{
return new vec3d(
(this.Y * right.Z) - (this.Z * right.Y),
(this.X * right.Z) - (this.Z * right.X),
(this.X * right.Y) - (this.Y * right.X)
);
get { return new vec3d(v); }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float Dot(vec3d right)
{
return Vector3.Dot(v,right.v);
return Vector3.Dot(v, right.v);
}
public bool Equals(vec3d other)
@@ -178,20 +180,10 @@ namespace StgSharp.Math
return new vec3d(vec.v / value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe implicit operator vec3d((float, float, float) tuple)
{
vec3d v = *(vec3d*)&tuple;
v.vec.W = 0.0f;
return v;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static vec3d operator +(vec3d left, vec3d right)
{
return new vec3d(
left.vec + right.vec
);
return new vec3d(left.vec + right.vec);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -200,17 +192,25 @@ namespace StgSharp.Math
return left.v == right.v;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe implicit operator vec3d((float, float, float) tuple)
{
vec3d v = *(vec3d*)&tuple;
v.vec.W = 0.0f;
return v;
}
}
public static class Vec3d
{
public static bool IsParallel(vec3d left, vec3d right)
{
return Cross(left,right) == Zero;
}
public static vec3d One => new vec3d(1, 1, 1);
public static vec3d UnitX => new vec3d(1, 0, 0);
public static vec3d UnitY => new vec3d(0, 1, 0);
public static vec3d UnitZ => new vec3d(0, 0, 1);
public static vec3d Zero => new vec3d(0, 0, 0);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static vec3d Cross(vec3d left, vec3d right)
@@ -218,11 +218,10 @@ namespace StgSharp.Math
return Linear.Cross(left, right);
}
public static vec3d One => new vec3d(1, 1, 1);
public static vec3d Zero => new vec3d(0, 0, 0);
public static bool IsParallel(vec3d left, vec3d right)
{
return Cross(left, right) == Zero;
}
public static vec3d UnitZ => new vec3d(0, 0, 1);
public static vec3d UnitX => new vec3d(1, 0, 0);
public static vec3d UnitY => new vec3d(0, 1, 0);
}
}