daily update on 20230927 by nitload youmu, all polygon4 display available, optimizing on C/C# interoperation

This commit is contained in:
Nitload
2023-09-28 01:43:27 +08:00
parent 5d701bce0c
commit 6c3349f5a2
130 changed files with 3280 additions and 25074 deletions
+17
View File
@@ -16,6 +16,22 @@ namespace StgSharp
CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
internal static extern unsafe int InternalInitGLAD();
[DllImport(SSGC_libname, EntryPoint = "loadShaderCode",
CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe uint InternalLoadShaderCode(byte* shaderCode, int shaderType);
[DllImport(SSGC_libname, EntryPoint = "linkShaderProgram",
CallingConvention = CallingConvention.Cdecl)]
internal static extern uint InternalLinkShaderProgram(uint shaderProgram);
[DllImport(SSGC_libname, EntryPoint = "readLog",
CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe IntPtr InternalReadLog();
#region GLFW
[DllImport(SSGC_libname, EntryPoint = "glfwGetWindowUserPointer",
CallingConvention = CallingConvention.Cdecl)]
@@ -393,6 +409,7 @@ namespace StgSharp
[DllImport(SSGC_libname, EntryPoint = "byte*", CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe byte* glfwGetClipboardString(GLFWwindow* window);
#endregion
//
+1 -6
View File
@@ -1,9 +1,4 @@
//
#define WINDOWS
//#define LINUX
//#define MACOS
//#define IOS
//#define ANDROID
using StgSharp.Geometries;
using System;
@@ -12,11 +12,11 @@ namespace StgSharp.Geometries
internal GetLocationHandler movBeginOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
internal GetLocationHandler movEndOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
public override Point RefPoint01 => center;
public override Point RefPoint0 => center;
public override Point RefPoint02 => beginPoint;
public override Point RefPoint1 => beginPoint;
public override Point RefPoint03 => endPoint;
public override Point RefPoint2 => endPoint;
public virtual Vec3d MoveCenter(uint tick) => movCenterOperation.Invoke(tick);
@@ -13,11 +13,11 @@ namespace StgSharp.Geometries
internal GetLocationHandler movEndOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
public override Point RefPoint01 => center;
public override Point RefPoint0 => center;
public override Point RefPoint02 => pointOnCircle;
public override Point RefPoint1 => pointOnCircle;
public override Point RefPoint03 => pointOnPlain;
public override Point RefPoint2 => pointOnPlain;
public virtual Vec3d MoveCenter(uint tick) => movCenterOperation.Invoke(tick);
@@ -11,12 +11,9 @@
public Point RefOrigin { get { return refOrigin; } }
public abstract Point RefPoint01
{
get;
}
public abstract Point RefPoint02 { get; }
public abstract Point RefPoint03 { get; }
public abstract Point RefPoint0 { get; }
public abstract Point RefPoint1 { get; }
public abstract Point RefPoint2 { get; }
public uint BornTime => bornTick;
public IPlainGeometry(uint bornTime)
@@ -1,19 +1,20 @@
using StgSharp.Math;
using System;
using System.Numerics;
namespace StgSharp.Geometries
{
public class Line : IPlainGeometry
{
internal Point basePoint = new Point();
internal Point beginPoint = new Point();
internal Point endPoint = new Point();
internal Point basePoint;
internal Point beginPoint;
internal Point endPoint;
internal GetLocationHandler movBegin;
internal GetLocationHandler movEnd;
public override Point RefPoint01 => beginPoint;
public override Point RefPoint02 => endPoint;
public override Point RefPoint03 => default;
public override Point RefPoint0 => beginPoint;
public override Point RefPoint1 => endPoint;
public override Point RefPoint2 => default;
public Line(Point begin, Point end)
{
@@ -21,6 +22,12 @@ namespace StgSharp.Geometries
this.endPoint = end;
}
internal Line(Vector4 begin, Vector4 end)
{
beginPoint = new Point(begin);
endPoint = new Point(end);
}
public Line() { }
//计算线起点的方法,通过对线的派生的重写实现功能
@@ -7,15 +7,15 @@ namespace StgSharp.Geometries
{
internal Point center;
public sealed override Point RefPoint01 => center;
public sealed override Point RefPoint02 => vertex01;
public sealed override Point RefPoint03 => vertex02;
public sealed override Point RefPoint0 => center;
public sealed override Point RefPoint1 => new Point(vertexMat.mat.colum0);
public sealed override Point RefPoint2 => new Point(vertexMat.mat.colum1);
internal readonly GetLocationHandler movCenterOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
public GetLocationHandler MovCenterOperation { get { return movCenterOperation; } }
public GetLocationHandler MovVertex01Operation { get { return movVertex01Operation; } }
public GetLocationHandler MovVertex02Operation { get { return movVertex02Operation; } }
public GetLocationHandler MovVertex01Operation { get { return moveVertex0Operation; } }
public GetLocationHandler MovVertex02Operation { get { return moveVertex1Operation; } }
public virtual Vec3d MovCenter(uint tick)
{
@@ -28,7 +28,7 @@ namespace StgSharp.Geometries
/// <param name="tick">Current time tick</param>
/// <returns></returns>
/// <exception cref="UnusedVertexException">Geometry overdefined</exception>
public sealed override Vec3d MovVertex03(uint tick)
public sealed override Vec3d MoveVertex2(uint tick)
{
throw new UnusedVertexException();
}
@@ -39,7 +39,7 @@ namespace StgSharp.Geometries
/// <param name="tick">Current time tick</param>
/// <returns></returns>
/// <exception cref="UnusedVertexException">Geometry overdefined</exception>
public sealed override Vec3d MovVertex04(uint tick)
public sealed override Vec3d MoveVertex3(uint tick)
{
throw new UnusedVertexException();
}
@@ -47,10 +47,10 @@ namespace StgSharp.Geometries
internal sealed override void OnRender(uint tick)
{
uint nowTick = TimeLine.tickCounter._value;
this.vertex01.Position = RefOrigin.Position + movVertex01Operation(nowTick);
this.vertex02.Position = RefOrigin.Position + movVertex02Operation(nowTick);
this.vertex03.Position = center.Position * 2 - vertex01.Position;
this.vertex04.Position = center.Position * 2 - vertex02.Position;
this.vertexMat.Colum0 = RefOrigin.Position + moveVertex0Operation(nowTick);
this.vertexMat.Colum1 = RefOrigin.Position + moveVertex1Operation(nowTick);
this.vertexMat.Colum2 = center.Position * 2 - vertexMat.Colum0;
this.vertexMat.Colum3 = center.Position * 2 - vertexMat.Colum1;
}
}
@@ -1,4 +1,5 @@
using StgSharp.Math;
using System.Numerics;
namespace StgSharp.Geometries
{
@@ -11,6 +12,14 @@ namespace StgSharp.Geometries
internal Vec3d plainParameter;
internal readonly float d = -1;
internal Plain(Vector4 origin, Vector4 p1, Vector4 p2)
{
this.origin = new Vec3d(origin);
vec1 = new Vec3d(p1 - origin);
vec2 = new Vec3d(p2 - origin);
}
public Plain(Vec3d o, Vec3d v1, Vec3d v2)
{
this.origin = o;
@@ -1,5 +1,6 @@
using StgSharp.Math;
using System;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Threading;
@@ -10,14 +11,21 @@ namespace StgSharp.Geometries
internal Vec3d position;
internal readonly bool isVertex;
public Point() { }
internal Point(Vec3d p)
{
position = p;
}
public Point()
internal Point(Vector4 vector)
{
position = new Vec3d(vector);
}
public Point(float x, float y, float z)
{
position = new Vec3d(x, y, z);
}
public Vec3d Position
@@ -5,27 +5,37 @@ namespace StgSharp.Geometries
{
public class Polygon4 : IPlainGeometry
{
internal Matrix3x4 vertexMat;
internal readonly Point vertex01;
internal readonly Point vertex02;
internal readonly Point vertex03;
internal readonly Point vertex04;
internal Point vertex0 { get; set; }
internal Point vertex1 { get; set; }
internal Point vertex2 { get; set; }
internal Point vertex3 { get; set; }
internal readonly GetLocationHandler movVertex01Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
internal readonly GetLocationHandler movVertex02Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
internal readonly GetLocationHandler movVertex03Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
internal readonly GetLocationHandler movVertex04Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
internal readonly GetLocationHandler moveVertex0Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
internal readonly GetLocationHandler moveVertex1Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
internal readonly GetLocationHandler moveVertex2Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
internal readonly GetLocationHandler moveVertex3Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
public override Point RefPoint01 => vertex01;
public override Point RefPoint0
{
get { return new Point(vertexMat.transpose.colum0); }
}
public override Point RefPoint02 => vertex02;
public override Point RefPoint1
{
get { return new Point(vertexMat.transpose.colum1); }
}
public override Point RefPoint03 => vertex03;
public override Point RefPoint2
{
get { return new Point(vertexMat.transpose.colum2); }
}
public GetLocationHandler MovVertex01Operaion { get { return movVertex01Operation; } }
public GetLocationHandler MovVertex02Operaion { get { return movVertex02Operation; } }
public GetLocationHandler MovVertex03Operaion { get { return movVertex03Operation; } }
public GetLocationHandler MovVertex04Operaion { get { return movVertex04Operation; } }
public GetLocationHandler MovVertex01Operaion { get { return moveVertex0Operation; } }
public GetLocationHandler MovVertex02Operaion { get { return moveVertex1Operation; } }
public GetLocationHandler MovVertex03Operaion { get { return moveVertex2Operation; } }
public GetLocationHandler MovVertex04Operaion { get { return moveVertex3Operation; } }
public unsafe Polygon4()
{
@@ -35,10 +45,10 @@ namespace StgSharp.Geometries
{
Line[] sides = new Line[4]
{
new Line(vertex01,vertex02),
new Line(vertex02, vertex03),
new Line(vertex03, vertex04),
new Line(vertex04, vertex01)
new Line(vertex0,vertex1),
new Line(vertex1, vertex2),
new Line(vertex2, vertex3),
new Line(vertex3, vertex0)
};
return sides;
@@ -46,26 +56,30 @@ namespace StgSharp.Geometries
public override Plain GetPlain()
{
return new Plain(this.RefPoint01, this.RefPoint02, this.RefPoint03);
vertexMat.InternalTranspose();
return new Plain(
vertexMat.mat.colum0,
vertexMat.mat.colum1,
vertexMat.mat.colum2);
}
public virtual Vec3d MovVertex01(uint tick) => movVertex01Operation.Invoke(tick);
public virtual Vec3d MoveVertex0(uint tick) => moveVertex0Operation.Invoke(tick);
public virtual Vec3d MovVertex02(uint tick) => movVertex01Operation.Invoke(tick);
public virtual Vec3d MoveVertex1(uint tick) => moveVertex1Operation.Invoke(tick);
public virtual Vec3d MovVertex03(uint tick) => movVertex01Operation.Invoke(tick);
public virtual Vec3d MoveVertex2(uint tick) => moveVertex2Operation.Invoke(tick);
public virtual Vec3d MovVertex04(uint tick) => movVertex01Operation.Invoke(tick);
public virtual Vec3d MoveVertex3(uint tick) => moveVertex3Operation.Invoke(tick);
internal override void OnRender(uint tick)
{
uint nowTick = TimeLine.tickCounter._value;
this.vertex01.Position = RefOrigin.Position + movVertex01Operation(nowTick);
this.vertex02.Position = RefOrigin.Position + movVertex02Operation(nowTick);
this.vertex03.Position = RefOrigin.Position + movVertex03Operation(nowTick);
this.vertex04.Position = RefOrigin.Position + movVertex04Operation(nowTick);
this.vertexMat.Colum0 = RefOrigin.position + moveVertex1Operation(nowTick);
this.vertexMat.Colum1 = RefOrigin.position + moveVertex1Operation(nowTick);
this.vertexMat.Colum2 = RefOrigin.position + moveVertex2Operation(nowTick);
this.vertexMat.Colum3 = RefOrigin.position + moveVertex3Operation(nowTick);
}
}
}
@@ -14,11 +14,11 @@ namespace StgSharp.Geometries
internal readonly Point vertex5;
internal readonly int _vertexCount;
public override Point RefPoint01 => vertex1;
public override Point RefPoint0 => vertex1;
public override Point RefPoint02 => vertex2;
public override Point RefPoint1 => vertex2;
public override Point RefPoint03 => vertex3;
public override Point RefPoint2 => vertex3;
internal GetLocationHandler movP01Operation = default;
internal GetLocationHandler movP02Operation = default;
@@ -14,11 +14,11 @@ namespace StgSharp.Geometries
internal Point vertex6;
internal readonly int _vertexCount;
public override Point RefPoint01 => vertex1;
public override Point RefPoint0 => vertex1;
public override Point RefPoint02 => vertex2;
public override Point RefPoint1 => vertex2;
public override Point RefPoint03 => vertex3;
public override Point RefPoint2 => vertex3;
internal GetLocationHandler movP01Operation = default;
@@ -1,4 +1,5 @@
using StgSharp.Math;
using System.Numerics;
namespace StgSharp.Geometries
{
@@ -6,11 +7,24 @@ namespace StgSharp.Geometries
{
internal Point center;
public sealed override Point RefPoint01 => center;
public sealed override Point RefPoint0 => center;
public sealed override Point RefPoint02 => vertex01;
public sealed override Point RefPoint1 => new Point(vertexMat.transpose.colum0);
public sealed override Point RefPoint03 => vertex02;
public sealed override Point RefPoint2 => new Point(vertexMat.transpose.colum1);
public Rectangle(
float v0x, float v0y, float v0z,
float v1x, float v1y, float v1z,
float v2x, float v2y, float v2z,
float v3x, float v3y, float v3z
)
{
vertexMat.mat.colum0 = new Vector4(v0x, v0y, v0z, 0);
vertexMat.mat.colum1 = new Vector4(v1x, v1y, v1z, 0);
vertexMat.mat.colum2 = new Vector4(v2x, v2y, v2z, 0);
vertexMat.mat.colum3 = new Vector4(v3x, v3y, v3z, 0);
}
@@ -21,14 +35,16 @@ namespace StgSharp.Geometries
/// <returns></returns>
public virtual Vec3d MovCenter(uint tick) => default(Vec3d);
public sealed override Vec3d MovVertex03(uint tick)
public sealed override Vec3d MoveVertex2(uint tick)
{
return this.center.Position * 2 - this.vertex01.Position;
return
new Vec3d(this.center.position.vec * 2 - vertexMat.mat.colum0);
}
public sealed override Vec3d MovVertex04(uint tick)
public sealed override Vec3d MoveVertex3(uint tick)
{
return this.center.Position * 2 - this.vertex02.Position;
return
new Vec3d(this.center.position.vec * 2 - vertexMat.mat.colum1);
}
internal sealed override void OnRender(uint tick)
@@ -1,4 +1,5 @@
using StgSharp.Math;
using System.Numerics;
namespace StgSharp.Geometries
{
@@ -8,9 +9,21 @@ namespace StgSharp.Geometries
/// </summary>
public class Square : Rectangle
{
public sealed override Vec3d MovVertex02(uint tick)
public Square(
float v0x, float v0y, float v0z,
float v1x, float v1y, float v1z,
float v2x, float v2y, float v2z,
float v3x, float v3y, float v3z)
: base(v0x, v0y, v0z,
v1x, v1y, v1z,
v2x, v2y, v2z,
v3x, v3y, v3z)
{
return this.center.Position * 2 - this.vertex01.Position;
}
public sealed override Vec3d MoveVertex1(uint tick)
{
return this.center.Position * 2 - this.vertexMat.Colum0;
}
}
@@ -1,5 +1,6 @@
using StgSharp.Controlling;
using StgSharp.Math;
using System.Numerics;
namespace StgSharp.Geometries
{
@@ -8,16 +9,15 @@ namespace StgSharp.Geometries
public unsafe class Triangle : IPlainGeometry
{
internal Point vertex1 = new Point();
internal Point vertex2 = new Point();
internal Point vertex3 = new Point();
internal Matrix3x3 vertexMap;
internal GetLocationHandler movVertex01Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
internal GetLocationHandler movVertex02Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
internal GetLocationHandler movVertex03Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
public sealed override Point RefPoint01 => vertex1;
public sealed override Point RefPoint02 => vertex2;
public sealed override Point RefPoint03 => vertex3;
public sealed override Point RefPoint0 => new Point(vertexMap.mat.colum0);
public sealed override Point RefPoint1 => new Point(vertexMap.mat.colum1);
public sealed override Point RefPoint2 => new Point(vertexMap.mat.colum2);
public GetLocationHandler MovVertex01Operation => this.movVertex01Opearion;
public GetLocationHandler MovVertex02Operation => this.movVertex02Opearion;
@@ -31,18 +31,7 @@ namespace StgSharp.Geometries
public Triangle()
{
this.vertex1 = new Point();
this.vertex2 = new Point();
this.vertex3 = new Point();
/*
TimeLine._currentPool._pointContainer.Add(vertex1);
TimeLine._currentPool._pointContainer.Add(vertex2);
TimeLine._currentPool._pointContainer.Add(vertex3);
/**/
vertexMap = new Matrix3x3();
}
public Triangle(
@@ -51,26 +40,37 @@ namespace StgSharp.Geometries
Vec3d vertex03
)
{
vertex1.Position = vertex01;
vertex2.Position = vertex02;
vertex3.Position = vertex03;
vertexMap.mat.colum0 = vertex01.vec;
vertexMap.mat.colum1 = vertex02.vec;
vertexMap.mat.colum2 = vertex03.vec;
}
public Triangle(
float v0x, float v0y, float v0z,
float v1x, float v1y, float v1z,
float v2x, float v2y, float v2z
)
{
vertexMap.mat.colum0 = new Vector4(v0x, v0y, v0z, 0);
vertexMap.mat.colum1 = new Vector4(v1x, v1y, v1z, 0);
vertexMap.mat.colum2 = new Vector4(v2x, v2y, v2z, 0);
}
internal sealed override void OnRender(uint tick)
{
tick -= this.bornTick;
vertex1.Position = RefOrigin.Position + MovVertex01(tick);
vertex2.Position = RefOrigin.Position + MovVertex02(tick);
vertex3.Position = RefOrigin.Position + MovVertex03(tick);
vertexMap.mat.colum0 = RefOrigin.Position.vec + MovVertex01(tick).vec;
vertexMap.mat.colum1 = RefOrigin.Position.vec + MovVertex02(tick).vec;
vertexMap.mat.colum2 = RefOrigin.Position.vec + MovVertex03(tick).vec;
}
public override Line[] GetAllSides()
{
Line[] sides = new Line[3]
{
new Line(vertex1,vertex2),
new Line(vertex2,vertex3),
new Line(vertex3,vertex1)
new Line(vertexMap.mat.colum0,vertexMap.mat.colum1),
new Line(vertexMap.mat.colum1,vertexMap.mat.colum2),
new Line(vertexMap.mat.colum2,vertexMap.mat.colum0)
};
return sides;
@@ -78,7 +78,7 @@ namespace StgSharp.Geometries
public override Plain GetPlain()
{
return new Plain(this.vertex1, this.vertex2, this.vertex3);
return new Plain(this.vertexMap.mat.colum0, this.vertexMap.mat.colum1, this.vertexMap.mat.colum2);
}
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -110,7 +110,7 @@ namespace StgSharp
#if DEBUG
Console.WriteLine(name);
#endif
return (IntPtr)0b1111111111;
return internalIO.glfwGetProcAddress(name);
}
else
{
+4 -4
View File
@@ -1912,7 +1912,7 @@ namespace StgSharp
internal unsafe delegate void PFNGLDELETEBUFFERSPROC(int n, uint* buffers);
internal unsafe delegate void PFNGLGENBUFFERSPROC(int n, uint* buffers);
internal unsafe delegate bool PFNGLISBUFFERPROC(uint buffer);
internal unsafe delegate void PFNGLBUFFERDATAPROC(int target, int* size, void* data, int usage);
internal unsafe delegate void PFNGLBUFFERDATAPROC(int target, int size, void* data, int usage);
internal unsafe delegate void PFNGLBUFFERSUBDATAPROC(int target, long offset, int* size, void* data);
internal unsafe delegate void PFNGLGETBUFFERSUBDATAPROC(int target, long offset, int* size, void* data);
internal unsafe delegate void PFNGLMAPBUFFERPROC(int target, int access);
@@ -1944,9 +1944,9 @@ namespace StgSharp
internal unsafe delegate void PFNGLGETATTACHEDSHADERSPROC(uint program, int maxCount, int* count, uint* shaders);
internal unsafe delegate int PFNGLGETATTRIBLOCATIONPROC(uint program, sbyte* name);
internal unsafe delegate void PFNGLGETPROGRAMIVPROC(uint program, int pname, int* parameters);
internal unsafe delegate void PFNGLGETPROGRAMINFOLOGPROC(uint program, int bufSize, int* length, sbyte* infoLog);
internal unsafe delegate void PFNGLGETPROGRAMINFOLOGPROC(uint program, int bufSize, int* length, byte* infoLog);
internal unsafe delegate void PFNGLGETSHADERIVPROC(uint shader, int pname, int* parameters);
internal unsafe delegate void PFNGLGETSHADERINFOLOGPROC(uint shader, int bufSize, int* length, sbyte* infoLog);
internal unsafe delegate void PFNGLGETSHADERINFOLOGPROC(uint shader, int bufSize, int* length, byte* infoLog);
internal unsafe delegate void PFNGLGETSHADERSOURCEPROC(uint shader, int bufSize, int* length, sbyte* source);
internal unsafe delegate int PFNGLGETUNIFORMLOCATIONPROC(uint program, sbyte* name);
internal unsafe delegate void PFNGLGETUNIFORMFVPROC(uint program, int location, float* parameters);
@@ -1958,7 +1958,7 @@ namespace StgSharp
internal unsafe delegate bool PFNGLISPROGRAMPROC(uint program);
internal unsafe delegate bool PFNGLISSHADERPROC(uint shader);
internal unsafe delegate void PFNGLLINKPROGRAMPROC(uint program);
internal unsafe delegate void PFNGLSHADERSOURCEPROC(uint shader, int count, sbyte** str, int* length);
internal unsafe delegate void PFNGLSHADERSOURCEPROC(uint shader, int count, byte** str, int* length);
internal unsafe delegate void PFNGLUSEPROGRAMPROC(uint program);
internal unsafe delegate void PFNGLUNIFORM1FPROC(int location, float v0);
internal unsafe delegate void PFNGLUNIFORM2FPROC(int location, float v0, float v1);
+8 -35
View File
@@ -62,41 +62,14 @@ namespace StgSharp
{
throw new Exception("Do not init GLAD twice.");
}
}
/*
/// <summary>
/// Init a form, attach its data to GLFW program,
/// and return the pointer of the GLFW package of the form.
/// </summary>
/// <param name="form">The C# instance of the form</param>
/// <returns>Pointer of the GLFW package of this form</returns>
/// <exception cref="Exception">The issue that form is not successfully initilized
/// or GLAD program fail to init</exception>
public static unsafe IntPtr InitWindow(Form form)
{
IntPtr a = internalIO.InternalInitWindow(form.info);
if ((long)a == -1)
{
throw new Exception("Failed to init form.");
}
else if ((long)a == -2)
{
throw new Exception("Failed to load GLAD program.");
}
else
{
return a;
}
}
*/
}
}
@@ -1,6 +1,9 @@
namespace StgSharp.Math
using System.Numerics;
using System.Runtime.CompilerServices;
namespace StgSharp.Math
{
public unsafe static partial class Vector
public unsafe static partial class VectorCalc
{
public static Vec3d To3D(Vec2d vec)
{
@@ -26,6 +29,11 @@
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static Vec3d To3D(Vector4 vector)
{
return new Vec3d(vector);
}
}
+38 -36
View File
@@ -11,17 +11,19 @@ namespace StgSharp.Math
[FieldOffset(0)] internal Mat3 mat;
[FieldOffset(3 * 4 * sizeof(float))] internal Mat3 transpose;
[FieldOffset(6 * 4 * sizeof(float))] internal bool isTransposed;
[FieldOffset(0 * 4 * sizeof(float))] public Vec3d Colum0;
[FieldOffset(1 * 4 * sizeof(float))] public Vec3d Colum1;
[FieldOffset(2 * 4 * sizeof(float))] public Vec3d Colum2;
public Matrix3x3(
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
)
{
mat.colum0 = new Vector4(a00,a10,a20,0);
mat.colum1 = new Vector4(a01,a11,a21,0);
mat.colum2 = new Vector4(a02,a12,a22,0);
mat.colum0 = new Vector4(a00, a10, a20, 0);
mat.colum1 = new Vector4(a01, a11, a21, 0);
mat.colum2 = new Vector4(a02, a12, a22, 0);
}
internal Matrix3x3(
@@ -129,7 +131,7 @@ namespace StgSharp.Math
mat.mat.colum2 * value
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Matrix3x3 operator /(Matrix3x3 mat, float value)
{
@@ -145,33 +147,33 @@ namespace StgSharp.Math
{
left.InternalTranspose();
return new Matrix3x2(
Vector4.Dot(left.transpose.colum0,right.mat.colum0),
Vector4.Dot(left.transpose.colum0,right.mat.colum1),
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
Vector4.Dot(left.transpose.colum1,right.mat.colum0),
Vector4.Dot(left.transpose.colum1,right.mat.colum1),
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
Vector4.Dot(left.transpose.colum2,right.mat.colum0),
Vector4.Dot(left.transpose.colum2,right.mat.colum1)
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
Vector4.Dot(left.transpose.colum2, right.mat.colum1)
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Matrix3x3 operator *(Matrix3x3 left, Matrix3x3 right)
{
left.InternalTranspose();
return new Matrix3x3(
Vector4.Dot(left.transpose.colum0,right.mat.colum0),
Vector4.Dot(left.transpose.colum0,right.mat.colum1),
Vector4.Dot(left.transpose.colum0,right.mat.colum2),
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
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.colum0),
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
Vector4.Dot(left.transpose.colum1, right.mat.colum2),
Vector4.Dot(left.transpose.colum2,right.mat.colum0),
Vector4.Dot(left.transpose.colum2,right.mat.colum1),
Vector4.Dot(left.transpose.colum2,right.mat.colum2)
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
Vector4.Dot(left.transpose.colum2, right.mat.colum2)
);
}
@@ -180,20 +182,20 @@ namespace StgSharp.Math
{
left.InternalTranspose();
return new Matrix3x4(
Vector4.Dot(left.transpose.colum0,right.mat.colum0),
Vector4.Dot(left.transpose.colum0,right.mat.colum1),
Vector4.Dot(left.transpose.colum0,right.mat.colum2),
Vector4.Dot(left.transpose.colum0,right.mat.colum3),
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
Vector4.Dot(left.transpose.colum0, right.mat.colum3),
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.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.colum2,right.mat.colum0),
Vector4.Dot(left.transpose.colum2,right.mat.colum1),
Vector4.Dot(left.transpose.colum2,right.mat.colum2),
Vector4.Dot(left.transpose.colum2,right.mat.colum3)
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
Vector4.Dot(left.transpose.colum2, right.mat.colum2),
Vector4.Dot(left.transpose.colum2, right.mat.colum3)
);
}
+16 -10
View File
@@ -1,4 +1,5 @@
using System;
using System.Drawing;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -6,13 +7,18 @@ using System.Runtime.InteropServices;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit, Size = 7*4*sizeof(float)+ sizeof(bool),Pack = 16)]
[StructLayout(LayoutKind.Explicit, Size = 7 * 4 * sizeof(float) + sizeof(bool), Pack = 16)]
public struct Matrix3x4
{
[FieldOffset(0)] internal Mat4 mat;
[FieldOffset(4*4*sizeof(float))] internal Mat3 transpose;
[FieldOffset(4 * 4 * sizeof(float))] internal Mat3 transpose;
[FieldOffset(7 * 4 * sizeof(float))] internal bool isTransposed;
[FieldOffset(0 * 4 * sizeof(float))] public Vec3d Colum0;
[FieldOffset(1 * 4 * sizeof(float))] public Vec3d Colum1;
[FieldOffset(2 * 4 * sizeof(float))] public Vec3d Colum2;
[FieldOffset(3 * 4 * sizeof(float))] public Vec3d Colum3;
public Matrix3x4(
float a00, float a01, float a02, float a03,
float a10, float a11, float a12, float a13,
@@ -90,8 +96,8 @@ namespace StgSharp.Math
{
if (!isTransposed)
{
fixed(Mat4* source = &this.mat)
fixed(Mat3* target = &this.transpose)
fixed (Mat4* source = &this.mat)
fixed (Mat3* target = &this.transpose)
{
internalIO.Transpose4to3_internal(source, target);
}
@@ -150,10 +156,10 @@ namespace StgSharp.Math
return new Matrix3x2(
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
Vector4.Dot(left.transpose.colum1, right.mat.colum0),
Vector4.Dot(left.transpose.colum1, right.mat.colum1),
Vector4.Dot(left.transpose.colum2, right.mat.colum0),
Vector4.Dot(left.transpose.colum2, right.mat.colum1)
);
@@ -167,11 +173,11 @@ namespace StgSharp.Math
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
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.colum2, right.mat.colum0),
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
Vector4.Dot(left.transpose.colum2, right.mat.colum2)
@@ -187,12 +193,12 @@ namespace StgSharp.Math
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
Vector4.Dot(left.transpose.colum0, right.mat.colum3),
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.colum2, right.mat.colum0),
Vector4.Dot(left.transpose.colum2, right.mat.colum1),
Vector4.Dot(left.transpose.colum2, right.mat.colum2),
+10 -5
View File
@@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit,Size = 16,Pack = 16)]
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
public struct Vec3d
{
[FieldOffset(0)]
@@ -22,7 +22,12 @@ namespace StgSharp.Math
X = x; Y = y; Z = z;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal Vec3d(Vector4 vector)
{
vec = vector;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec3d operator +(Vec3d vec1, Vec3d vec2)
{
@@ -57,9 +62,9 @@ namespace StgSharp.Math
public static Vec3d operator /(Vec3d vec, float value)
{
return new Vec3d(
vec.X/value,
vec.Y/value,
vec.Z/value
vec.X / value,
vec.Y / value,
vec.Z / value
);
}
@@ -60,7 +60,7 @@
平面几何体。包含三角形,对称四边形,自由多边形等。最多可由16个点参数定义。
</summary>
</member>
<member name="M:StgSharp.Geometries.Parallelogram.MovVertex03(System.UInt32)">
<member name="M:StgSharp.Geometries.Parallelogram.MoveVertex2(System.UInt32)">
<summary>
Move the third vertix. this is a useless method for Parallelograms.
</summary>
@@ -68,7 +68,7 @@
<returns></returns>
<exception cref="T:StgSharp.Geometries.UnusedVertexException">Geometry overdefined</exception>
</member>
<member name="M:StgSharp.Geometries.Parallelogram.MovVertex04(System.UInt32)">
<member name="M:StgSharp.Geometries.Parallelogram.MoveVertex3(System.UInt32)">
<summary>
Move the third vertix. This method is useless for Parallelograms.
</summary>
@@ -70,7 +70,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.400\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.401\\RuntimeIdentifierGraph.json"
}
}
}
+1 -1
View File
@@ -203,7 +203,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.400\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.401\\RuntimeIdentifierGraph.json"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "laAh6HOqaqkeza4HK3EBhAx7AjcOlrd8Z6s26b8lsUCoYM8PIJh/NJy8SIv8UHq9F9mqp0Pw10DuCZW5/r5x5g==",
"dgSpecHash": "n9Xi4iZXV3QSFntRckZHzDXaJisY2FvKlYNQrLaVsXhG7L0GmeGCz292aaGFg24/a22cdlby5Tm2bmC2jHfvQA==",
"success": true,
"projectFilePath": "D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\源代码\\StgSharp\\StgSharp.csproj",
"expectedPackageFiles": [
@@ -60,7 +60,7 @@
平面几何体。包含三角形,对称四边形,自由多边形等。最多可由16个点参数定义。
</summary>
</member>
<member name="M:StgSharp.Geometries.Parallelogram.MovVertex03(System.UInt32)">
<member name="M:StgSharp.Geometries.Parallelogram.MoveVertex2(System.UInt32)">
<summary>
Move the third vertix. this is a useless method for Parallelograms.
</summary>
@@ -68,7 +68,7 @@
<returns></returns>
<exception cref="T:StgSharp.Geometries.UnusedVertexException">Geometry overdefined</exception>
</member>
<member name="M:StgSharp.Geometries.Parallelogram.MovVertex04(System.UInt32)">
<member name="M:StgSharp.Geometries.Parallelogram.MoveVertex3(System.UInt32)">
<summary>
Move the third vertix. This method is useless for Parallelograms.
</summary>