daily uodate on 20231208 by nitload youmu, preparation for multi thread rendering
This commit is contained in:
@@ -12,12 +12,6 @@ namespace StgSharp.Geometries
|
||||
internal GetLocationHandler movBeginOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movEndOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
public override Point RefPoint0 => center;
|
||||
|
||||
public override Point RefPoint1 => beginPoint;
|
||||
|
||||
public override Point RefPoint2 => endPoint;
|
||||
|
||||
internal override int[] Indices => throw new NotImplementedException();
|
||||
|
||||
public virtual vec3d MoveCenter(uint tick) => movCenterOperation.Invoke(tick);
|
||||
@@ -26,12 +20,12 @@ namespace StgSharp.Geometries
|
||||
|
||||
public virtual vec3d MovEnd(uint tick) => movEndOperation.Invoke(tick);
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
internal override void UpdateCoordinate(uint tick)
|
||||
{
|
||||
tick -= bornTick;
|
||||
center.Position = refOrigin.Position + MoveCenter(tick);
|
||||
beginPoint.Position = refOrigin.Position + MovBegin(tick);
|
||||
endPoint.Position = refOrigin.Position + MovEnd(tick);
|
||||
center.Position = this.coordinate.origin + MoveCenter(tick);
|
||||
beginPoint.Position = this.coordinate.origin + MovBegin(tick);
|
||||
endPoint.Position = this.coordinate.origin + MovEnd(tick);
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides() => throw new NotImplementedException();
|
||||
@@ -40,5 +34,6 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
return new Plain(this.center, this.beginPoint, this.endPoint);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,6 @@ namespace StgSharp.Geometries
|
||||
internal GetLocationHandler movEndOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
|
||||
public override Point RefPoint0 => center;
|
||||
|
||||
public override Point RefPoint1 => pointOnCircle;
|
||||
|
||||
public override Point RefPoint2 => pointOnPlain;
|
||||
|
||||
internal override int[] Indices => throw new NotImplementedException();
|
||||
|
||||
public virtual vec3d MoveCenter(uint tick) => movCenterOperation.Invoke(tick);
|
||||
@@ -32,12 +26,12 @@ namespace StgSharp.Geometries
|
||||
return new Plain(center, pointOnCircle, pointOnPlain);
|
||||
}
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
internal override void UpdateCoordinate(uint tick)
|
||||
{
|
||||
tick -= bornTick;
|
||||
center.Position = refOrigin.Position + MoveCenter(tick);
|
||||
pointOnCircle.Position = refOrigin.Position + UpdateRadius(tick);
|
||||
pointOnPlain.Position = refOrigin.Position + UpdatePlain(tick);
|
||||
center.Position = this.coordinate.origin + MoveCenter(tick);
|
||||
pointOnCircle.Position = this.coordinate.origin + UpdateRadius(tick);
|
||||
pointOnPlain.Position = this.coordinate.origin + UpdatePlain(tick);
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PartialPlainCoordinate
|
||||
{
|
||||
/// <summary>
|
||||
/// The origin of this coordinate.
|
||||
/// </summary>
|
||||
public vec3d origin;
|
||||
internal Matrix3x2 axis;
|
||||
|
||||
/// <summary>
|
||||
/// The horizontial axis of the coordinate.
|
||||
/// Point to the right direction.
|
||||
/// </summary>
|
||||
public vec3d axis_H
|
||||
{
|
||||
get { return axis.colum0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The vertical axis of the coordinate.
|
||||
/// Point to the top direction.
|
||||
/// </summary>
|
||||
public vec3d axis_V
|
||||
{
|
||||
get { return axis.colum1; }
|
||||
}
|
||||
|
||||
public PartialPlainCoordinate
|
||||
(
|
||||
vec3d origin,
|
||||
vec3d horiziontial,
|
||||
vec3d vertical
|
||||
)
|
||||
{
|
||||
this.origin = origin;
|
||||
axis = new Matrix3x2();
|
||||
#if NET5_0_OR_GREATER
|
||||
Unsafe.SkipInit(out axis.mat);
|
||||
#endif
|
||||
axis.colum0 = horiziontial;
|
||||
axis.colum1 = vertical;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public vec3d GetRealLocate(Vec2d raletiveLocation)
|
||||
{
|
||||
return origin + axis.VerticalVecMultiply(raletiveLocation);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,6 @@ namespace StgSharp.Geometries
|
||||
internal GetLocationHandler movBegin;
|
||||
internal GetLocationHandler movEnd;
|
||||
|
||||
public override Point RefPoint0 => beginPoint;
|
||||
public override Point RefPoint1 => endPoint;
|
||||
public override Point RefPoint2 => default;
|
||||
|
||||
internal override int[] Indices
|
||||
{
|
||||
@@ -35,7 +32,7 @@ namespace StgSharp.Geometries
|
||||
|
||||
public Line() { }
|
||||
|
||||
//计算线起点的方法,通过对线的派生的重写实现功能
|
||||
//method to calculate begin point of the the line
|
||||
public virtual vec3d MoveBeginPoint(uint tick)
|
||||
=> movBegin.Invoke(tick);
|
||||
|
||||
@@ -43,11 +40,11 @@ namespace StgSharp.Geometries
|
||||
public virtual vec3d MoveEndPoint(uint tick)
|
||||
=> movEnd.Invoke(tick);
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
internal override void UpdateCoordinate(uint tick)
|
||||
{
|
||||
tick -= bornTick;
|
||||
beginPoint.Position = refOrigin.Position + MoveBeginPoint(tick);
|
||||
endPoint.Position = refOrigin.Position + MoveEndPoint(tick);
|
||||
beginPoint.Position = coordinate.origin + MoveBeginPoint(tick);
|
||||
endPoint.Position = coordinate.origin + MoveEndPoint(tick);
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
|
||||
@@ -7,10 +7,6 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
internal Point center;
|
||||
|
||||
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);
|
||||
|
||||
@@ -66,13 +62,9 @@ namespace StgSharp.Geometries
|
||||
throw new UnusedVertexException();
|
||||
}
|
||||
|
||||
internal sealed override void OnRender(uint tick)
|
||||
internal sealed override void UpdateCoordinate(uint tick)
|
||||
{
|
||||
uint nowTick = TimeLine.tickCounter._value;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,13 +9,14 @@ namespace StgSharp.Geometries
|
||||
public abstract class PlainGeometry
|
||||
{
|
||||
protected readonly uint bornTick;
|
||||
internal readonly Point refOrigin;
|
||||
|
||||
public Point RefOrigin { get { return refOrigin; } }
|
||||
internal PartialPlainCoordinate coordinate;
|
||||
internal Matrix2x4 textureFrame;
|
||||
|
||||
public abstract Point RefPoint0 { get; }
|
||||
public abstract Point RefPoint1 { get; }
|
||||
public abstract Point RefPoint2 { get; }
|
||||
public PartialPlainCoordinate ReferenceCoordinate
|
||||
{
|
||||
get => this.coordinate;
|
||||
}
|
||||
|
||||
public uint BornTime => bornTick;
|
||||
|
||||
@@ -33,13 +34,14 @@ namespace StgSharp.Geometries
|
||||
|
||||
public PlainGeometry() { }
|
||||
|
||||
|
||||
internal abstract void OnRender(uint tick);
|
||||
internal abstract void UpdateCoordinate(uint tick);
|
||||
|
||||
public abstract Line[] GetAllSides();
|
||||
|
||||
public abstract Plain GetPlain();
|
||||
|
||||
//public abstract Rectangle GetRenderFrame();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,12 +11,43 @@ namespace StgSharp.Geometries
|
||||
internal readonly GetLocationHandler moveVertex2Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal readonly GetLocationHandler moveVertex3Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
internal Matrix3x4 vertexMat;
|
||||
internal Matrix2x4 vertexMat;
|
||||
|
||||
internal Polygon4()
|
||||
{
|
||||
}
|
||||
|
||||
public Polygon4(PartialPlainCoordinate coordinate,
|
||||
Vec2d topLeft,
|
||||
Vec2d topRight,
|
||||
Vec2d bottomRight,
|
||||
Vec2d bottomLeft,
|
||||
bool Orth
|
||||
)
|
||||
{
|
||||
this.coordinate = coordinate;
|
||||
vertexMat.Colum0 = topLeft;
|
||||
vertexMat.Colum1 = topRight;
|
||||
vertexMat.Colum2 = bottomRight;
|
||||
vertexMat.Colum3 = bottomLeft;
|
||||
|
||||
Vector4 maxCoord = vertexMat.mat.colum0;
|
||||
Vector4 minCoord = vertexMat.mat.colum0;
|
||||
|
||||
maxCoord = Vector4.Max(maxCoord, vertexMat.mat.colum1);
|
||||
maxCoord = Vector4.Max(maxCoord, vertexMat.mat.colum2);
|
||||
maxCoord = Vector4.Max(maxCoord, vertexMat.mat.colum3);
|
||||
|
||||
minCoord = Vector4.Min(minCoord, vertexMat.mat.colum1);
|
||||
minCoord = Vector4.Min(minCoord, vertexMat.mat.colum2);
|
||||
minCoord = Vector4.Min(minCoord, vertexMat.mat.colum3);
|
||||
|
||||
textureFrame.mat.colum1 = maxCoord;
|
||||
textureFrame.mat.colum3 = minCoord;
|
||||
textureFrame.Colum0 = new Vec2d(minCoord.X, maxCoord.Y);
|
||||
textureFrame.Colum2 = new Vec2d(maxCoord.X, minCoord.Y);
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
float v0x, float v0y, float v0z,
|
||||
float v1x, float v1y, float v1z,
|
||||
@@ -35,20 +66,7 @@ namespace StgSharp.Geometries
|
||||
public GetLocationHandler MovVertex2Operaion { get { return moveVertex2Operation; } }
|
||||
public GetLocationHandler MovVertex3Operaion { get { return moveVertex3Operation; } }
|
||||
|
||||
public override Point RefPoint0
|
||||
{
|
||||
get { return new Point(vertexMat.mat.colum0); }
|
||||
}
|
||||
|
||||
public override Point RefPoint1
|
||||
{
|
||||
get { return new Point(vertexMat.mat.colum1); }
|
||||
}
|
||||
|
||||
public override Point RefPoint2
|
||||
{
|
||||
get { return new Point(vertexMat.mat.colum2); }
|
||||
}
|
||||
|
||||
internal sealed override int[] Indices
|
||||
{
|
||||
@@ -89,6 +107,7 @@ namespace StgSharp.Geometries
|
||||
set { vertexMat.mat.colum1 = value.position.vec; }
|
||||
}
|
||||
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
Line[] sides = new Line[4]
|
||||
@@ -112,25 +131,22 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
public virtual vec3d MoveVertex0(uint tick)
|
||||
=> moveVertex0Operation.Invoke(tick);
|
||||
=> moveVertex0Operation(tick);
|
||||
|
||||
public virtual vec3d MoveVertex1(uint tick)
|
||||
=> moveVertex1Operation.Invoke(tick);
|
||||
=> moveVertex1Operation(tick);
|
||||
|
||||
public virtual vec3d MoveVertex2(uint tick)
|
||||
=> moveVertex2Operation.Invoke(tick);
|
||||
=> moveVertex2Operation(tick);
|
||||
|
||||
public virtual vec3d MoveVertex3(uint tick)
|
||||
=> moveVertex3Operation.Invoke(tick);
|
||||
=> moveVertex3Operation(tick);
|
||||
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
|
||||
internal override void UpdateCoordinate(uint tick)
|
||||
{
|
||||
uint nowTick = TimeLine.tickCounter._value;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +41,6 @@ namespace StgSharp.Geometries
|
||||
public GetLocationHandler MovP04Operation { get => movP04Operation; }
|
||||
public GetLocationHandler MovP05Operation { get => movP05Operation; }
|
||||
|
||||
public override Point RefPoint0 => Vertex0;
|
||||
public override Point RefPoint1 => Vertex1;
|
||||
public override Point RefPoint2 => Vertex2;
|
||||
|
||||
public mat5 VertexBuffer
|
||||
{
|
||||
get { return vertexMat; }
|
||||
@@ -118,14 +114,14 @@ namespace StgSharp.Geometries
|
||||
public virtual vec3d movVertex05(uint tick) => movP05Operation.Invoke(TimeLine.tickCounter._value);
|
||||
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
internal override void UpdateCoordinate(uint tick)
|
||||
{
|
||||
uint nowTick = tick - BornTime;
|
||||
vertexMat.vec0 = (RefOrigin.Position + movVertex01(nowTick)).vec;
|
||||
vertexMat.vec1 = (RefOrigin.Position + movVertex02(nowTick)).vec;
|
||||
vertexMat.vec2 = (RefOrigin.Position + movVertex03(nowTick)).vec;
|
||||
vertexMat.vec3 = (RefOrigin.Position + movVertex04(nowTick)).vec;
|
||||
vertexMat.vec4 = (RefOrigin.Position + movVertex05(nowTick)).vec;
|
||||
vertexMat.vec0 = (coordinate.origin + movVertex01(nowTick)).vec;
|
||||
vertexMat.vec1 = (coordinate.origin + movVertex02(nowTick)).vec;
|
||||
vertexMat.vec2 = (coordinate.origin + movVertex03(nowTick)).vec;
|
||||
vertexMat.vec3 = (coordinate.origin + movVertex04(nowTick)).vec;
|
||||
vertexMat.vec4 = (coordinate.origin + movVertex05(nowTick)).vec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace StgSharp.Geometries
|
||||
internal GetLocationHandler movVertex5Operation;
|
||||
internal mat6 vertexMat;
|
||||
|
||||
|
||||
public GetLocationHandler MovVertex0Operation { get => movVertex0Operation; }
|
||||
public GetLocationHandler MovVertex1Operation { get => movVertex1Operation; }
|
||||
public GetLocationHandler MovVertex2Operation { get => movVertex2Operation; }
|
||||
@@ -24,10 +23,6 @@ namespace StgSharp.Geometries
|
||||
public GetLocationHandler MovVertex4Operation { get => movVertex4Operation; }
|
||||
public GetLocationHandler MovVertex5Operation { get => movVertex5Operation; }
|
||||
|
||||
public override Point RefPoint0 => Vertex0;
|
||||
public override Point RefPoint1 => Vertex1;
|
||||
public override Point RefPoint2 => Vertex2;
|
||||
|
||||
internal override int[] Indices
|
||||
{
|
||||
get
|
||||
@@ -124,10 +119,10 @@ namespace StgSharp.Geometries
|
||||
return movVertex5Operation.Invoke(TimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
internal override void UpdateCoordinate(uint tick)
|
||||
{
|
||||
uint nowTick = tick - BornTime;
|
||||
Vector4 origin = RefOrigin.Position.vec;
|
||||
Vector4 origin = coordinate.origin.vec;
|
||||
vertexMat.vec0 = origin + movVertex0(nowTick).vec;
|
||||
vertexMat.vec1 = origin + movVertex1(nowTick).vec;
|
||||
vertexMat.vec2 = origin + movVertex2(nowTick).vec;
|
||||
|
||||
@@ -19,16 +19,14 @@ namespace StgSharp.Geometries
|
||||
v3x, v2y, v3z
|
||||
)
|
||||
{
|
||||
vec3d side0 = vertexMat.Colum0 - vertexMat.Colum1;
|
||||
vec3d side1 = vertexMat.Colum2 - vertexMat.Colum1;
|
||||
if (side0.Cross(side1) == Vec3d.Zero)
|
||||
Vec2d side0 = vertexMat.Colum0 - vertexMat.Colum1;
|
||||
Vec2d side1 = vertexMat.Colum2 - vertexMat.Colum1;
|
||||
if (side0.Cross(side1) == 0)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 计算中心点相对于参考原点的位移
|
||||
/// </summary>
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace StgSharp.Geometries
|
||||
|
||||
public sealed override vec3d MoveVertex1(uint tick)
|
||||
{
|
||||
return this.center.Position * 2 - this.vertexMat.Colum0;
|
||||
return default;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,9 +45,6 @@ namespace StgSharp.Geometries
|
||||
public GetLocationHandler MovVertex01Operation => this.movVertex01Opearion;
|
||||
public GetLocationHandler MovVertex02Operation => this.movVertex02Opearion;
|
||||
public GetLocationHandler MovVertex03Operation => this.movVertex03Opearion;
|
||||
public sealed override Point RefPoint0 => new Point(vertexMat.mat.colum0);
|
||||
public sealed override Point RefPoint1 => new Point(vertexMat.mat.colum1);
|
||||
public sealed override Point RefPoint2 => new Point(vertexMat.mat.colum2);
|
||||
|
||||
public Mat3 VertexBuffer
|
||||
{
|
||||
@@ -81,12 +78,13 @@ namespace StgSharp.Geometries
|
||||
public virtual vec3d MovVertex02(uint tick) => movVertex02Opearion.Invoke(tick);
|
||||
|
||||
public virtual vec3d MovVertex03(uint tick) => movVertex03Opearion.Invoke(tick);
|
||||
internal sealed override void OnRender(uint tick)
|
||||
|
||||
internal sealed override void UpdateCoordinate(uint tick)
|
||||
{
|
||||
tick -= this.bornTick;
|
||||
vertexMat.mat.colum0 = RefOrigin.Position.vec + MovVertex01(tick).vec;
|
||||
vertexMat.mat.colum1 = RefOrigin.Position.vec + MovVertex02(tick).vec;
|
||||
vertexMat.mat.colum2 = RefOrigin.Position.vec + MovVertex03(tick).vec;
|
||||
vertexMat.mat.colum0 = coordinate.origin.vec + MovVertex01(tick).vec;
|
||||
vertexMat.mat.colum1 = coordinate.origin.vec + MovVertex02(tick).vec;
|
||||
vertexMat.mat.colum2 = coordinate.origin.vec + MovVertex03(tick).vec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user