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
@@ -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);
}
}