daily update on 20240528 by nitload youmu

This commit is contained in:
Nitload
2024-05-28 17:45:54 +08:00
parent de399e22c2
commit 70890e3e33
88 changed files with 10678 additions and 5761 deletions
@@ -14,7 +14,6 @@ namespace StgSharp.Geometries
public vec2d CenterPosition { get; set; }
public bool CollideWith(IPlainEntity entity);
}
public class PlainEntity:IPlainEntity
@@ -0,0 +1,86 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="IInstancing.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Geometries
{
public class ParticleOnPlain : IInstancing, IPlainEntity
{
public ParticleOnPlain(PlainInstancingBuffer<ParticleOnPlain> buffer)
{
if (buffer == null)
{
throw new ArgumentNullException(paramName: nameof(buffer));
}
GlobalBuffer = buffer;
BufferId = buffer.CreateInstanceID();
((IInstancingBuffer)buffer).InstanceList.Add(this);
}
public int BufferId
{
get;
set;
}
public IInstancingBuffer GlobalBuffer
{
get;
set;
}
public GeometryMotion Motion
{
get;
set;
}
vec3d IInstancing.CenterPositionGlobal
{
get;
set;
}
vec2d IPlainEntity.CenterPosition { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
bool IPlainEntity.CollideWith(IPlainEntity entity)
{
throw new NotImplementedException();
}
}
}
@@ -32,68 +32,39 @@ using StgSharp.Graphics;
using StgSharp.Math;
using System;
using System.ComponentModel;
namespace StgSharp.Geometries
{
/// <summary>
/// 平面几何体。包含三角形,对称四边形,自由多边形等。最多可由16个点参数定义。
/// Plain geometry only contains straight sides.
/// </summary>
public abstract class PlainGeometry: IGeometry
public abstract class PlainGeometry : IGeometry
{
protected TimeSpanProvider time;
protected vec4d[] vertexMat;
internal ICoord coordinate;
public static int VertexCount { get; }
public PlainGeometry()
{
}
vec4d IGeometry.this[int index]
public vec4d this[int index]
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
get => vertexMat[index];
set => vertexMat[index] = value;
}
/// <summary>
/// Tick time this geometry eas crested
/// </summary>
public int BornTime => time;
public ICoord ReferenceCoordinate => this.coordinate;
internal abstract int[] Indices { get; }
public int VertexCount => this.vertexMat.Length;
int IGeometry.VertexCount => throw new NotImplementedException();
public abstract ReadOnlySpan<int> VertexIndices { get; }
vec4d[] IGeometry.VertexStream => throw new NotImplementedException();
#pragma warning disable CA1819
public vec4d[] VertexStream => vertexMat;
#pragma warning restore CA1819
/// <summary>
/// Get all sides of this <see cref="PlainGeometry"/>.
/// </summary>
/// <returns>A array contains all straight <see cref="Line"/>s of current geometry item.</returns>
public abstract Line[] GetAllSides();
/// <summary>
/// Get a flat <see cref="Plain"/> coincide with current geometry.
/// </summary>
/// <returns></returns>
public abstract Plain GetPlain();
internal abstract void UpdateCoordinate(int tick);
void IGeometry.GetVertexHandle(ICoord coordinate, int count)
{
throw new NotImplementedException();
}
void IGeometry.Transform(Matrix44 transFormMatrix)
{
throw new NotImplementedException();
}
//public abstract Rectangle GetRenderFrame();
}
}
@@ -44,12 +44,15 @@ using System.Threading.Tasks;
namespace StgSharp.Geometries
{
public class PlainInstancingBuffer<T> : IDisposable,IEnumerable<T> where T : IInstancing<T>
public class PlainInstancingBuffer<T> :
IDisposable,IEnumerable<T>, IInstancingBuffer
where T :
IInstancing
{
private CoordinatePlain globalCorrdinnate;
private List<vec4d> coordList;
private List<IInstancing<T>> instanceList;
private List<IInstancing> instanceList;
private List<float> scalingList;
private Mutex mutex;
private bool disposedValue;
@@ -64,29 +67,29 @@ namespace StgSharp.Geometries
public PlainInstancingBuffer()
{
coordList = new List<vec4d>(capacity: 100);
instanceList = new List<IInstancing<T>>(capacity:100);
instanceList = new List<IInstancing>(capacity:100);
scalingList = new List<float>(capacity: 100);
coordArray = new vec4d[0];
scaleArray = new float[0];
coordArray = Array.Empty<vec4d>();
scaleArray = Array.Empty<float>();
mutex = new Mutex();
}
internal List<IInstancing<T>> InstanceList
List<IInstancing> IInstancingBuffer.InstanceList
{
get => instanceList;
}
internal List<vec4d> CoordList
List<vec4d> IInstancingBuffer.CoordAndRotationList
{
get => coordList;
}
internal List<float> ScalingList
List<float> IInstancingBuffer.ScalingList
{
get => scalingList;
}
public Span<vec4d> CoordSpan
public Span<vec4d> CoordAndRotationSpan
{
get
{
@@ -96,7 +99,11 @@ namespace StgSharp.Geometries
GetField("_items", BindingFlags.NonPublic | BindingFlags.Instance);
if (fieldInfo == null)
{
#pragma warning disable CA1065
#pragma warning disable CA2201
throw new NullReferenceException();
#pragma warning restore CA2201
#pragma warning restore CA1065
}
coordArray = (vec4d[])fieldInfo.GetValue(coordList);
}
@@ -114,7 +121,11 @@ namespace StgSharp.Geometries
GetField("_items", BindingFlags.NonPublic | BindingFlags.Instance);
if (fieldInfo == null)
{
#pragma warning disable CA1065
#pragma warning disable CA2201
throw new NullReferenceException();
#pragma warning restore CA2201
#pragma warning restore CA1065
}
scaleArray = (float[])fieldInfo.GetValue(scalingList);
}
@@ -122,6 +133,8 @@ namespace StgSharp.Geometries
}
}
IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException();
public int CreateInstanceID()
{
mutex.WaitOne();
@@ -142,7 +155,7 @@ namespace StgSharp.Geometries
paramName: nameof(instance));
}
int index = instance.BufferId;
IInstancing<T> temp = instanceList[instanceList.Count - 1];
IInstancing temp = instanceList[instanceList.Count - 1];
instanceList[instance.BufferId] = temp;
temp.BufferId = instance.BufferId;
@@ -28,7 +28,7 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Controlling;
using StgSharp.Math;
using System;
@@ -56,48 +56,14 @@ namespace StgSharp.Geometries
)
{
if (
vertexMat.colum0 + vertexMat.colum2 !=
vertexMat.colum1 + vertexMat.colum3
this[0] + this[2] !=
this[1] + this[3]
)
{
InternalIO.InternalWriteLog("Init of geometry item failed, because four vertices cannot form a rectangle.", LogType.Warning);
}
}
public Func<int,vec3d> MovCenterOperation => movCenterOperation;
public Func<int,vec3d> MovVertex01Operation => moveVertex0Operation;
public Func<int,vec3d> MovVertex02Operation => moveVertex1Operation;
public virtual vec3d MovCenter(int tick)
{
return movCenterOperation.Invoke(tick);
}
/// <summary>
/// Move the third vertex. this is a useless method for Parallelograms.
/// </summary>
/// <param name="tick">Current time tick</param>
/// <returns></returns>
/// <exception cref="UnusedVertexException">Geometry over defined</exception>
public override sealed vec3d MoveVertex2(int tick)
{
throw new UnusedVertexException();
}
/// <summary>
/// Move the third vertex. This method is useless for Parallelograms.
/// </summary>
/// <param name="tick">Current time tick</param>
/// <returns></returns>
/// <exception cref="UnusedVertexException">Geometry over defined</exception>
public override sealed vec3d MoveVertex3(int tick)
{
throw new UnusedVertexException();
}
internal override sealed void UpdateCoordinate(int tick)
{
}
}
}
@@ -92,11 +92,6 @@ namespace StgSharp.Geometries
throw new NotImplementedException();
}
public bool IsOnPlain(PlainGeometry geo)
{
return position * geo.GetPlain().plainParameter == 1;
}
/// <summary>
/// Update the coordinate of the point. If this is a moving point,
@@ -28,7 +28,7 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Controlling;
using StgSharp.Math;
using System;
@@ -38,41 +38,35 @@ namespace StgSharp.Geometries
{
public class Polygon4 : PlainGeometry
{
internal readonly Func<int,vec3d> moveVertex0Operation = GeometryOperation.DefaultMotion;
internal readonly Func<int,vec3d> moveVertex1Operation = GeometryOperation.DefaultMotion;
internal readonly Func<int,vec3d> moveVertex2Operation = GeometryOperation.DefaultMotion;
internal readonly Func<int,vec3d> moveVertex3Operation = GeometryOperation.DefaultMotion;
internal Mat4 vertexMat;
protected static int[] Indices = [0, 1, 2, 0, 2, 3];
internal Polygon4()
{
}
public Polygon4(ICoord coordinate,
vec2d topLeft,
vec2d topRight,
vec2d bottomRight,
vec2d bottomLeft
vec3d topLeft,
vec3d topRight,
vec3d bottomRight,
vec3d bottomLeft
)
{
this.coordinate = coordinate;
vertexMat.colum0 = topLeft.vec;
vertexMat.colum1 = topRight.vec;
vertexMat.colum2 = bottomRight.vec;
vertexMat.colum3 = bottomLeft.vec;
this[0] = new vec4d(topLeft.vec);
this[1] = new vec4d(topRight.vec);
this[2] = new vec4d(bottomRight.vec);
this[3] = new vec4d(bottomLeft.vec);
Vector4 maxCoord = vertexMat.colum0;
Vector4 minCoord = vertexMat.colum0;
Vector4 maxCoord = this[0].vec;
Vector4 minCoord = this[0].vec;
maxCoord = Vector4.Max(maxCoord, vertexMat.colum1);
maxCoord = Vector4.Max(maxCoord, vertexMat.colum2);
maxCoord = Vector4.Max(maxCoord, vertexMat.colum3);
maxCoord = Vector4.Max(maxCoord, this[1].vec);
maxCoord = Vector4.Max(maxCoord, this[2].vec);
maxCoord = Vector4.Max(maxCoord, this[3].vec);
minCoord = Vector4.Min(minCoord, vertexMat.colum1);
minCoord = Vector4.Min(minCoord, vertexMat.colum2);
minCoord = Vector4.Min(minCoord, vertexMat.colum3);
minCoord = Vector4.Min(minCoord, this[1].vec);
minCoord = Vector4.Min(minCoord, this[2].vec);
minCoord = Vector4.Min(minCoord, this[3].vec);
}
public Polygon4(
@@ -82,92 +76,15 @@ namespace StgSharp.Geometries
float v3x, float v3y, float v3z
)
{
vertexMat.colum0 = new Vector4(v0x, v0y, v0z, 0);
vertexMat.colum1 = new Vector4(v1x, v1y, v1z, 0);
vertexMat.colum2 = new Vector4(v2x, v2y, v2z, 0);
vertexMat.colum3 = new Vector4(v3x, v3y, v3z, 0);
vertexMat = new vec4d[4];
this[0] = new vec4d(v0x, v0y, v0z, 0);
this[1] = new vec4d(v1x, v1y, v1z, 0);
this[2] = new vec4d(v2x, v2y, v2z, 0);
this[3] = new vec4d(v3x, v3y, v3z, 0);
}
public Func<int,vec3d> MovVertex0Operation => moveVertex0Operation;
public Func<int,vec3d> MovVertex1Operation => moveVertex1Operation;
public Func<int,vec3d> MovVertex2Operation => moveVertex2Operation;
public Func<int,vec3d> MovVertex3Operation => moveVertex3Operation;
public Point Vertex0
{
get => new Point(vertexMat.colum0);
set => vertexMat.colum0 = value.position.vec;
}
public Point Vertex1
{
get => new Point(vertexMat.colum1);
set => vertexMat.colum1 = value.position.vec;
}
public Point Vertex2
{
get => new Point(vertexMat.colum2);
set => vertexMat.colum1 = value.position.vec;
}
public Mat4 VertexBuffer => vertexMat;
internal override sealed int[] Indices => new int[6] { 0, 1, 2, 0, 2, 3 };
internal Point Vertex3
{
get => new Point(vertexMat.colum3);
set => vertexMat.colum1 = value.position.vec;
}
public override Line[] GetAllSides()
{
Line[] sides =
[
new Line(Vertex0, Vertex1),
new Line(Vertex1, Vertex2),
new Line(Vertex2, Vertex3),
new Line(Vertex3, Vertex0)
];
return sides;
}
public override Plain GetPlain()
{
return new Plain(
vertexMat.colum0,
vertexMat.colum1,
vertexMat.colum2);
}
public virtual vec3d MoveVertex0(int tick)
{
return moveVertex0Operation(tick);
}
public virtual vec3d MoveVertex1(int tick)
{
return moveVertex1Operation(tick);
}
public virtual vec3d MoveVertex2(int tick)
{
return moveVertex2Operation(tick);
}
public virtual vec3d MoveVertex3(int tick)
{
return moveVertex3Operation(tick);
}
internal override void UpdateCoordinate(int tick)
{
}
public override ReadOnlySpan<int> VertexIndices => Indices;
}
}
@@ -28,7 +28,7 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Controlling;
using StgSharp.Math;
using System;
@@ -39,16 +39,9 @@ namespace StgSharp.Geometries
public unsafe class Polygon5 : PlainGeometry
{
internal Point _refOrigin;
internal Func<int,vec3d> movP01Operation = default;
internal Func<int,vec3d> movP02Operation = default;
internal Func<int,vec3d> movP03Operation = default;
internal Func<int,vec3d> movP04Operation = default;
internal Func<int,vec3d> movP05Operation = default;
internal mat5 vertexMat;
public unsafe Polygon5()
{
vertexMat = new vec4d[5];
}
public Polygon5(
@@ -59,106 +52,16 @@ namespace StgSharp.Geometries
float v4x, float v4y, float v4z
)
{
vertexMat.vec0 = new Vector4(v0x, v0y, v0z, 0);
vertexMat.vec1 = new Vector4(v1x, v1y, v1z, 0);
vertexMat.vec2 = new Vector4(v2x, v2y, v2z, 0);
vertexMat.vec3 = new Vector4(v3x, v3y, v3z, 0);
vertexMat.vec4 = new Vector4(v4x, v4y, v4z, 0);
vertexMat = new vec4d[5];
this[0] = new vec4d(v0x, v0y, v0z, 0);
this[1] = new vec4d(v1x, v1y, v1z, 0);
this[2] = new vec4d(v2x, v2y, v2z, 0);
this[3] = new vec4d(v3x, v3y, v3z, 0);
this[4] = new vec4d(v4x, v4y, v4z, 0);
}
internal static int[] Indices = [ 0, 1, 2, 0, 2, 3, 0, 3, 4 ];
public Func<int,vec3d> MovP01Operation => movP01Operation;
public Func<int,vec3d> MovP02Operation => movP02Operation;
public Func<int,vec3d> MovP03Operation => movP03Operation;
public Func<int,vec3d> MovP04Operation => movP04Operation;
public Func<int,vec3d> MovP05Operation => movP05Operation;
public Point Vertex0
{
get => new Point(vertexMat.vec0);
set => vertexMat.vec0 = value.position.vec;
}
public Point Vertex1
{
get => new Point(vertexMat.vec1);
set => vertexMat.vec1 = value.position.vec;
}
public Point Vertex2
{
get => new Point(vertexMat.vec2);
set => vertexMat.vec2 = value.position.vec;
}
public Point Vertex3
{
get => new Point(vertexMat.vec3);
set => vertexMat.vec3 = value.position.vec;
}
public Point Vertex4
{
get => new Point(vertexMat.vec4);
set => vertexMat.vec4 = value.position.vec;
}
public mat5 VertexBuffer => vertexMat;
internal override int[] Indices => new int[9] { 0, 1, 2, 0, 2, 3, 0, 3, 4 };
public override Line[] GetAllSides()
{
return new Line[5]
{
new Line(Vertex0,Vertex1),
new Line(Vertex1,Vertex2),
new Line(Vertex2,Vertex3),
new Line(Vertex3,Vertex4),
new Line(Vertex4,Vertex0)
};
}
public override Plain GetPlain()
{
return new Plain(Vertex0, Vertex1, Vertex2);
}
public virtual vec3d movVertex01(int tick)
{
return movP01Operation.Invoke(time);
}
public virtual vec3d movVertex02(int tick)
{
return movP02Operation.Invoke(time);
}
public virtual vec3d movVertex03(int tick)
{
return movP03Operation.Invoke(time);
}
public virtual vec3d movVertex04(int tick)
{
return movP04Operation.Invoke(time);
}
public virtual vec3d movVertex05(int tick)
{
return movP05Operation.Invoke(time);
}
internal override void UpdateCoordinate(int tick)
{
int nowTick = tick - BornTime;
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;
}
public override ReadOnlySpan<int> VertexIndices => Indices;
}
}
@@ -28,7 +28,7 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Controlling;
using StgSharp.Math;
using System;
@@ -38,120 +38,13 @@ namespace StgSharp.Geometries
{
public class Polygon6 : PlainGeometry
{
internal Point _refOrigin;
internal Func<int,vec3d> movVertex0Operation;
internal Func<int,vec3d> movVertex1Operation;
internal Func<int,vec3d> movVertex2Operation;
internal Func<int,vec3d> movVertex3Operation;
internal Func<int,vec3d> movVertex4Operation;
internal Func<int,vec3d> movVertex5Operation;
internal mat6 vertexMat;
public Func<int,vec3d> MovVertex0Operation => movVertex0Operation;
public Func<int,vec3d> MovVertex1Operation => movVertex1Operation;
public Func<int,vec3d> MovVertex2Operation => movVertex2Operation;
public Func<int,vec3d> MovVertex3Operation => movVertex3Operation;
public Func<int,vec3d> MovVertex4Operation => movVertex4Operation;
public Func<int,vec3d> MovVertex5Operation => movVertex5Operation;
public Point Vertex0
public Polygon6()
{
get => new Point(vertexMat.vec0);
set => vertexMat.vec0 = value.position.vec;
vertexMat = new vec4d[6];
}
public Point Vertex1
{
get => new Point(vertexMat.vec1);
set => vertexMat.vec1 = value.position.vec;
}
public Point Vertex2
{
get => new Point(vertexMat.vec2);
set => vertexMat.vec2 = value.position.vec;
}
public Point Vertex3
{
get => new Point(vertexMat.vec3);
set => vertexMat.vec3 = value.position.vec;
}
public Point Vertex4
{
get => new Point(vertexMat.vec4);
set => vertexMat.vec4 = value.position.vec;
}
public Point Vertex5
{
get => new Point(vertexMat.vec5);
set => vertexMat.vec5 = value.position.vec;
}
internal override int[] Indices => new int[12] { 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5 };
public override Line[] GetAllSides()
{
return new Line[6]
{
new Line(Vertex0,Vertex1),
new Line(Vertex1,Vertex2),
new Line(Vertex2,Vertex3),
new Line(Vertex3,Vertex4),
new Line(Vertex4,Vertex5),
new Line(Vertex5,Vertex0)
};
}
public override Plain GetPlain()
{
return new Plain(Vertex0, Vertex1, Vertex2);
}
public virtual vec3d movVertex0(int tick)
{
return movVertex0Operation.Invoke(time);
}
public virtual vec3d movVertex1(int tick)
{
return movVertex1Operation.Invoke(time);
}
public virtual vec3d movVertex2(int tick)
{
return movVertex2Operation.Invoke(time);
}
public virtual vec3d movVertex3(int tick)
{
return movVertex3Operation.Invoke(time);
}
public virtual vec3d movVertex4(int tick)
{
return movVertex4Operation.Invoke(time);
}
public virtual vec3d movVertex5(int tick)
{
return movVertex5Operation.Invoke(time);
}
internal override void UpdateCoordinate(int tick)
{
int nowTick = tick - BornTime;
Vector4 origin = coordinate.Origin.vec;
vertexMat.vec0 = origin + movVertex0(nowTick).vec;
vertexMat.vec1 = origin + movVertex1(nowTick).vec;
vertexMat.vec2 = origin + movVertex2(nowTick).vec;
vertexMat.vec3 = origin + movVertex3(nowTick).vec;
vertexMat.vec4 = origin + movVertex4(nowTick).vec;
vertexMat.vec5 = origin + movVertex5(nowTick).vec;
}
internal static int[] Indices = [ 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5 ];
public override ReadOnlySpan<int> VertexIndices => Indices;
}
}
@@ -50,8 +50,8 @@ namespace StgSharp.Geometries
)
{
#if DEBUG
vec2d side0 = new vec2d( vertexMat.colum0 - vertexMat.colum1);
vec2d side1 = new vec2d( vertexMat.colum2 - vertexMat.colum1);
vec2d side0 = (this[0] - this[1]).XY;
vec2d side1 = (this[2] - this[1]).XY;
if (side0.Cross(side1) == 0)
{
throw new ArgumentException();
@@ -51,12 +51,12 @@ namespace StgSharp.Geometries
v2x, v2y, v2z,
v3x, v3y, v3z)
{
if (true)
{
}
}
public override sealed vec3d MoveVertex1(int tick)
{
return default;
}
}
}
@@ -28,7 +28,8 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Controlling;
using StgSharp.Graphics;
using StgSharp.Math;
using System;
@@ -41,15 +42,9 @@ namespace StgSharp.Geometries
public unsafe class Triangle : PlainGeometry
{
internal Func<int,vec3d> movVertex01Operation = GeometryOperation.DefaultMotion;
internal Func<int,vec3d> movVertex02Operation = GeometryOperation.DefaultMotion;
internal Func<int,vec3d> movVertex03Operation = GeometryOperation.DefaultMotion;
internal Mat3 vertexMat;
public Triangle()
{
vertexMat = new Mat3();
vertexMat = new vec4d[3];
}
public Triangle(
@@ -58,9 +53,9 @@ namespace StgSharp.Geometries
vec3d vertex03
)
{
vertexMat.colum0 = vertex01.vec;
vertexMat.colum1 = vertex02.vec;
vertexMat.colum2 = vertex03.vec;
this[0] = new vec4d( vertex01.vec);
this[1] = new vec4d( vertex02.vec);
this[2] = new vec4d( vertex03.vec);
}
public Triangle(
@@ -69,56 +64,14 @@ namespace StgSharp.Geometries
float v2x, float v2y, float v2z
)
{
vertexMat.colum0 = new Vector4(v0x, v0y, v0z, 0);
vertexMat.colum1 = new Vector4(v1x, v1y, v1z, 0);
vertexMat.colum2 = new Vector4(v2x, v2y, v2z, 0);
this[0] = new vec4d(v0x, v0y, v0z, 0);
this[1] = new vec4d(v1x, v1y, v1z, 0);
this[2] = new vec4d(v2x, v2y, v2z, 0);
}
public Func<int,vec3d> MovVertex01Operation => this.movVertex01Operation;
public Func<int,vec3d> MovVertex02Operation => this.movVertex02Operation;
public Func<int,vec3d> MovVertex03Operation => this.movVertex03Operation;
internal static int[] Indices = [ 0, 1, 2 ];
public Mat3 VertexBuffer => vertexMat;
internal override sealed int[] Indices => new int[3] { 0, 1, 2 };
public override Line[] GetAllSides()
{
return
[
new Line(vertexMat.colum0,vertexMat.colum1),
new Line(vertexMat.colum1,vertexMat.colum2),
new Line(vertexMat.colum2,vertexMat.colum0)
];
}
public override Plain GetPlain()
{
return new Plain(this.vertexMat.colum0, this.vertexMat.colum1, this.vertexMat.colum2);
}
public virtual vec3d MovVertex01(int tick)
{
return movVertex01Operation(tick);
}
public virtual vec3d MovVertex02(int tick)
{
return movVertex02Operation(tick);
}
public virtual vec3d MovVertex03(int tick)
{
return movVertex03Operation(tick);
}
internal override sealed void UpdateCoordinate(int tick)
{
tick = time;
vertexMat.colum0 = coordinate.Origin.vec + MovVertex01(time).vec;
vertexMat.colum1 = coordinate.Origin.vec + MovVertex02(time).vec;
vertexMat.colum2 = coordinate.Origin.vec + MovVertex03(time).vec;
}
public override ReadOnlySpan<int> VertexIndices => Indices;
}
}