Daily update on 20250618-051714 by Nitload Youmu. Additional Message : Brief support to collection operation in EXPRESS. A collection type added in core lib and compilestack.
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -41,22 +41,16 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
private static PlainCoordinate statndardPlainCoordination = new PlainCoordinate(
|
||||
null, new Point( 0, 0, 0 ), new Vec3( 1, 0, 0 ),
|
||||
new Vec3( 0, 1, 0 ) );
|
||||
null, new Point( 0, 0, 0 ), new Vec3( 1, 0, 0 ), new Vec3( 0, 1, 0 ) );
|
||||
|
||||
public PlainCoordinate(
|
||||
CoordinationBase local,
|
||||
Point origin,
|
||||
Vec3 xAxis,
|
||||
Vec3 yAxis )
|
||||
public PlainCoordinate( CoordinationBase local, Point origin, Vec3 xAxis, Vec3 yAxis )
|
||||
: base( local )
|
||||
{
|
||||
CoordMat = Matrix44.Unit;
|
||||
|
||||
CoordMat.colum0 = new Vec4( xAxis, 0 );
|
||||
CoordMat.colum1 = new Vec4( yAxis, 0 );
|
||||
CoordMat.colum2 = new Vec4(
|
||||
Linear.Normalize( Vec3.Cross( xAxis, yAxis ) ), 0 );
|
||||
CoordMat.colum2 = new Vec4( Linear.Normalize( Vec3.Cross( xAxis, yAxis ) ), 0 );
|
||||
|
||||
LocalOrigin = origin;
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
public SpaceCoordinate(
|
||||
CoordinationBase localCoordination,
|
||||
Point origin,
|
||||
Vec3 xAxis,
|
||||
Vec3 yAxis,
|
||||
Vec3 zAxis )
|
||||
CoordinationBase localCoordination,
|
||||
Point origin,
|
||||
Vec3 xAxis,
|
||||
Vec3 yAxis,
|
||||
Vec3 zAxis )
|
||||
: base( localCoordination ) { }
|
||||
|
||||
}
|
||||
|
||||
@@ -36,31 +36,25 @@ namespace StgSharp.Geometries
|
||||
public unsafe class ToUpperDimensionException : Exception
|
||||
{
|
||||
|
||||
protected ToUpperDimensionException(
|
||||
SerializationInfo info,
|
||||
StreamingContext context )
|
||||
protected ToUpperDimensionException( SerializationInfo info, StreamingContext context )
|
||||
: base( info, context ) { }
|
||||
|
||||
public ToUpperDimensionException() { }
|
||||
|
||||
public ToUpperDimensionException( string message ) : base( message ) { }
|
||||
|
||||
public ToUpperDimensionException(
|
||||
string message,
|
||||
Exception innerException )
|
||||
public ToUpperDimensionException( string message, Exception innerException )
|
||||
: base( message, innerException ) { }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当几何体调用了过多的CalcVec方法时,产生UnusedVertexException异常
|
||||
/// 当几何体调用了过多的CalcVec方法时,产生UnusedVertexException异常
|
||||
/// </summary>
|
||||
public class UnusedVertexException : Exception
|
||||
{
|
||||
|
||||
protected UnusedVertexException(
|
||||
SerializationInfo info,
|
||||
StreamingContext context )
|
||||
protected UnusedVertexException( SerializationInfo info, StreamingContext context )
|
||||
: base( info, context ) { }
|
||||
|
||||
public UnusedVertexException() { }
|
||||
|
||||
@@ -40,9 +40,7 @@ using System.Text;
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
[UnmanagedFunctionPointer( CallingConvention.Cdecl )]
|
||||
public delegate Vec3 GeometryMotionDelegate(
|
||||
TimeSpanProvider timeSource,
|
||||
out float rotation );
|
||||
public delegate Vec3 GeometryMotionDelegate( TimeSpanProvider timeSource, out float rotation );
|
||||
|
||||
public class GeometryMotion
|
||||
{
|
||||
@@ -54,20 +52,23 @@ namespace StgSharp.Geometries
|
||||
private TimeSpanProvider time;
|
||||
|
||||
public unsafe GeometryMotion(
|
||||
bool isIncreament,
|
||||
TimeSpanProvider timeSource,
|
||||
GeometryMotionDelegate motionDelegate )
|
||||
bool isIncreament,
|
||||
TimeSpanProvider timeSource,
|
||||
GeometryMotionDelegate motionDelegate )
|
||||
{
|
||||
isIncrementMode = isIncreament;
|
||||
time = timeSource;
|
||||
if( motionDelegate == null ) {
|
||||
if( motionDelegate == null )
|
||||
{
|
||||
handle = ( IntPtr )( delegate*<TimeSpanProvider, out float, Vec3> )&defaultMotion;
|
||||
movement = defaultMotion;
|
||||
} else if( motionDelegate.Method.IsStatic ) {
|
||||
} else if( motionDelegate.Method.IsStatic )
|
||||
{
|
||||
sourceIsStatic = true;
|
||||
handle = Marshal.GetFunctionPointerForDelegate( motionDelegate );
|
||||
movement = motionDelegate;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
movement = motionDelegate;
|
||||
}
|
||||
|
||||
@@ -88,25 +89,27 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
float rot;
|
||||
Vec3 vec;
|
||||
if( sourceIsStatic ) {
|
||||
if( sourceIsStatic )
|
||||
{
|
||||
vec = ( ( delegate* unmanaged[Cdecl]<TimeSpanProvider, out float, Vec3> )handle )(
|
||||
time, out rot );
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
vec = movement( time, out rot );
|
||||
}
|
||||
|
||||
if( isIncrementMode ) {
|
||||
if( isIncrementMode )
|
||||
{
|
||||
coord += vec;
|
||||
rotation += rot;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
coord = vec;
|
||||
rotation = rot;
|
||||
}
|
||||
}
|
||||
|
||||
private static Vec3 defaultMotion(
|
||||
TimeSpanProvider provider,
|
||||
out float rotation )
|
||||
private static Vec3 defaultMotion( TimeSpanProvider provider, out float rotation )
|
||||
{
|
||||
rotation = 0;
|
||||
return Vec3.Zero;
|
||||
|
||||
@@ -42,33 +42,18 @@ namespace StgSharp.Geometries
|
||||
public interface IGeometry
|
||||
{
|
||||
|
||||
public Point this[ int index ]
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public Point this[ int index ] { get; set; }
|
||||
|
||||
#pragma warning disable CA1819
|
||||
public Vec4[] VertexStream
|
||||
#pragma warning restore CA1819
|
||||
{
|
||||
get;
|
||||
}
|
||||
#pragma warning restore CA1819
|
||||
{ get; }
|
||||
|
||||
public CoordinationBase Coordination
|
||||
{
|
||||
get;
|
||||
}
|
||||
public CoordinationBase Coordination { get; }
|
||||
|
||||
public int VertexCount
|
||||
{
|
||||
get;
|
||||
}
|
||||
public int VertexCount { get; }
|
||||
|
||||
public ReadOnlySpan<int> VertexIndices
|
||||
{
|
||||
get;
|
||||
}
|
||||
public ReadOnlySpan<int> VertexIndices { get; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,53 +43,29 @@ namespace StgSharp.Geometries
|
||||
public interface IInstancing
|
||||
{
|
||||
|
||||
public float Rotation
|
||||
{
|
||||
get { return GlobalBuffer.CoordAndRotationList[ BufferId ].W; }
|
||||
set
|
||||
{
|
||||
Vec4 temp = GlobalBuffer.CoordAndRotationList[ BufferId ];
|
||||
temp.W = value;
|
||||
GlobalBuffer.CoordAndRotationList[ BufferId ] = temp;
|
||||
}
|
||||
}
|
||||
public float Rotation { get { return GlobalBuffer.CoordAndRotationList[ BufferId ].W; } set
|
||||
{
|
||||
Vec4 temp = GlobalBuffer.CoordAndRotationList[
|
||||
BufferId ];
|
||||
temp.W = value;
|
||||
GlobalBuffer.CoordAndRotationList[
|
||||
BufferId ] = temp;
|
||||
} }
|
||||
|
||||
public float Scale
|
||||
{
|
||||
get { return GlobalBuffer.ScalingList[ BufferId ]; }
|
||||
set { GlobalBuffer.ScalingList[ BufferId ] = value; }
|
||||
}
|
||||
public float Scale { get { return GlobalBuffer.ScalingList[ BufferId ]; } set { GlobalBuffer.ScalingList[
|
||||
BufferId ] = value; } }
|
||||
|
||||
public GeometryMotion Motion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public GeometryMotion Motion { get; set; }
|
||||
|
||||
public IInstancingBuffer GlobalBuffer
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
public IInstancingBuffer GlobalBuffer { get; internal set; }
|
||||
|
||||
public int BufferId
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
public int BufferId { get; internal set; }
|
||||
|
||||
public Vec3 CenterPositionGlobal
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
public Vec3 CenterPositionGlobal { get; internal set; }
|
||||
|
||||
public Vec3 Coord
|
||||
{
|
||||
get { return GlobalBuffer.CoordAndRotationList[ BufferId ].XYZ; }
|
||||
set { GlobalBuffer.CoordAndRotationList[ BufferId ] = new Vec4(
|
||||
value.reg ); }
|
||||
}
|
||||
public Vec3 Coord { get { return GlobalBuffer.CoordAndRotationList[ BufferId ].XYZ; } set { GlobalBuffer.CoordAndRotationList[
|
||||
BufferId ] = new Vec4(
|
||||
value.reg ); } }
|
||||
|
||||
public void Move()
|
||||
{
|
||||
|
||||
@@ -39,35 +39,17 @@ namespace StgSharp.Geometries
|
||||
public interface IInstancingBuffer
|
||||
{
|
||||
|
||||
public Span<Vec4> CoordAndRotationSpan
|
||||
{
|
||||
get;
|
||||
}
|
||||
public Span<Vec4> CoordAndRotationSpan { get; }
|
||||
|
||||
public Span<float> ScalingSpan
|
||||
{
|
||||
get;
|
||||
}
|
||||
public Span<float> ScalingSpan { get; }
|
||||
|
||||
internal IGeometry TypicalShape
|
||||
{
|
||||
get;
|
||||
}
|
||||
internal IGeometry TypicalShape { get; }
|
||||
|
||||
internal List<IInstancing> InstanceList
|
||||
{
|
||||
get;
|
||||
}
|
||||
internal List<IInstancing> InstanceList { get; }
|
||||
|
||||
internal List<Vec4> CoordAndRotationList
|
||||
{
|
||||
get;
|
||||
}
|
||||
internal List<Vec4> CoordAndRotationList { get; }
|
||||
|
||||
internal List<float> ScalingList
|
||||
{
|
||||
get;
|
||||
}
|
||||
internal List<float> ScalingList { get; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,14 +47,11 @@ namespace StgSharp.Geometries
|
||||
internal Matrix32 axis;
|
||||
|
||||
/// <summary>
|
||||
/// The _origin of this coordinate.
|
||||
/// The _origin of this coordinate.
|
||||
/// </summary>
|
||||
public Vec3 origin;
|
||||
|
||||
public PartialPlainCoordinate(
|
||||
Vec3 origin,
|
||||
Vec3 horiziontial,
|
||||
Vec3 vertical )
|
||||
public PartialPlainCoordinate( Vec3 origin, Vec3 horiziontial, Vec3 vertical )
|
||||
{
|
||||
this.origin = origin;
|
||||
axis = new Matrix32();
|
||||
@@ -66,12 +63,12 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The horizontial axis of the coordinate. Point to the right direction.
|
||||
/// The horizontial axis of the coordinate. Point to the right direction.
|
||||
/// </summary>
|
||||
public Vec3 axis_H => axis.colum0;
|
||||
|
||||
/// <summary>
|
||||
/// The vertical axis of the coordinate. Point to the top direction.
|
||||
/// The vertical axis of the coordinate. Point to the top direction.
|
||||
/// </summary>
|
||||
public Vec3 axis_V => axis.colum1;
|
||||
|
||||
|
||||
@@ -41,11 +41,7 @@ namespace StgSharp.Geometries
|
||||
public interface IPlainEntity
|
||||
{
|
||||
|
||||
public Vec2 CenterPosition
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public Vec2 CenterPosition { get; set; }
|
||||
|
||||
public bool CollideWith( IPlainEntity entity );
|
||||
|
||||
|
||||
@@ -53,29 +53,13 @@ namespace StgSharp.Geometries
|
||||
( ( IInstancingBuffer )buffer ).InstanceList.Add( this );
|
||||
}
|
||||
|
||||
public GeometryMotion Motion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public GeometryMotion Motion { get; set; }
|
||||
|
||||
public IInstancingBuffer GlobalBuffer
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public IInstancingBuffer GlobalBuffer { get; set; }
|
||||
|
||||
public int BufferId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int BufferId { get; set; }
|
||||
|
||||
Vec3 IInstancing.CenterPositionGlobal
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
Vec3 IInstancing.CenterPositionGlobal { get; set; }
|
||||
|
||||
bool IPlainEntity.CollideWith( IPlainEntity entity )
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ using System.ComponentModel;
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
/// <summary>
|
||||
/// Plain geometry only contains straight sides.
|
||||
/// Plain geometry only contains straight sides.
|
||||
/// </summary>
|
||||
public abstract class PlainGeometry : IGeometry
|
||||
{
|
||||
@@ -58,10 +58,7 @@ namespace StgSharp.Geometries
|
||||
|
||||
public int VertexCount => this.vertexMat.Length;
|
||||
|
||||
public abstract ReadOnlySpan<int> VertexIndices
|
||||
{
|
||||
get;
|
||||
}
|
||||
public abstract ReadOnlySpan<int> VertexIndices { get; }
|
||||
|
||||
#pragma warning disable CA1819
|
||||
public Vec4[] VertexStream => vertexMat;
|
||||
|
||||
@@ -85,12 +85,12 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
get
|
||||
{
|
||||
if( coordArray.Length != coordList.Capacity ) {
|
||||
if( coordArray.Length != coordList.Capacity )
|
||||
{
|
||||
FieldInfo fieldInfo = typeof( List<Vec4> ).
|
||||
GetField(
|
||||
"_items",
|
||||
BindingFlags.NonPublic | BindingFlags.Instance );
|
||||
if( fieldInfo == null ) {
|
||||
GetField( "_items", BindingFlags.NonPublic | BindingFlags.Instance );
|
||||
if( fieldInfo == null )
|
||||
{
|
||||
#pragma warning disable CA1065
|
||||
#pragma warning disable CA2201
|
||||
throw new NullReferenceException();
|
||||
@@ -107,12 +107,12 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
get
|
||||
{
|
||||
if( scaleArray.Length != coordList.Capacity ) {
|
||||
if( scaleArray.Length != coordList.Capacity )
|
||||
{
|
||||
FieldInfo fieldInfo = typeof( List<float> ).
|
||||
GetField(
|
||||
"_items",
|
||||
BindingFlags.NonPublic | BindingFlags.Instance );
|
||||
if( fieldInfo == null ) {
|
||||
GetField( "_items", BindingFlags.NonPublic | BindingFlags.Instance );
|
||||
if( fieldInfo == null )
|
||||
{
|
||||
#pragma warning disable CA1065
|
||||
#pragma warning disable CA2201
|
||||
throw new NullReferenceException();
|
||||
@@ -167,8 +167,7 @@ namespace StgSharp.Geometries
|
||||
temp.BufferId = instance.BufferId;
|
||||
|
||||
coordList[ instance.BufferId ] = coordList[ coordList.Count - 1 ];
|
||||
scalingList[ instance.BufferId ] = scalingList[
|
||||
scalingList.Count - 1 ];
|
||||
scalingList[ instance.BufferId ] = scalingList[ scalingList.Count - 1 ];
|
||||
|
||||
instanceList.RemoveAt( instanceList.Count - 1 );
|
||||
coordList.RemoveAt( coordList.Count - 1 );
|
||||
@@ -185,7 +184,8 @@ namespace StgSharp.Geometries
|
||||
|
||||
protected virtual void Dispose( bool disposing )
|
||||
{
|
||||
if( !disposedValue ) {
|
||||
if( !disposedValue )
|
||||
{
|
||||
if( disposing ) {
|
||||
mutex.Dispose();
|
||||
}
|
||||
@@ -204,8 +204,7 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
}
|
||||
|
||||
IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException(
|
||||
);
|
||||
IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException();
|
||||
|
||||
#region field of mem opt
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
@@ -44,18 +43,19 @@ namespace StgSharp.Geometries
|
||||
internal Point center;
|
||||
|
||||
public Parallelogram(
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
: base( v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y )
|
||||
{
|
||||
#if DEBUG
|
||||
if( this[ 0 ].Coord + this[ 2 ].Coord != this[ 1 ].Coord + this[ 3 ].Coord ) {
|
||||
if( this[ 0 ].Coord + this[ 2 ].Coord != this[ 1 ].Coord + this[ 3 ].Coord )
|
||||
{
|
||||
InternalIO.InternalWriteLog(
|
||||
"Init of geometry item failed, because four vertices cannot form a rectangle.",
|
||||
LogType.Warning );
|
||||
@@ -64,19 +64,20 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
public Parallelogram(
|
||||
PlainCoordinate coordination,
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
PlainCoordinate coordination,
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
: base( coordination, v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y )
|
||||
{
|
||||
#if DEBUG
|
||||
if( this[ 0 ].Coord + this[ 2 ].Coord != this[ 1 ].Coord + this[ 3 ].Coord ) {
|
||||
if( this[ 0 ].Coord + this[ 2 ].Coord != this[ 1 ].Coord + this[ 3 ].Coord )
|
||||
{
|
||||
InternalIO.InternalWriteLog(
|
||||
"Init of geometry item failed, because four vertices cannot form a rectangle.",
|
||||
LogType.Warning );
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
@@ -56,11 +55,7 @@ namespace StgSharp.Geometries
|
||||
vertexMat = rawCoord;
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
Point topLeft,
|
||||
Point topRight,
|
||||
Point bottomRight,
|
||||
Point bottomLeft )
|
||||
public Polygon4( Point topLeft, Point topRight, Point bottomRight, Point bottomLeft )
|
||||
: base( PlainCoordinate.StandardPlainCoordination )
|
||||
{
|
||||
this[ 0 ] = topLeft;
|
||||
@@ -70,12 +65,12 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
CoordinationBase coordinate,
|
||||
PlainCoordinate coordination,
|
||||
Point topLeft,
|
||||
Point topRight,
|
||||
Point bottomRight,
|
||||
Point bottomLeft )
|
||||
CoordinationBase coordinate,
|
||||
PlainCoordinate coordination,
|
||||
Point topLeft,
|
||||
Point topRight,
|
||||
Point bottomRight,
|
||||
Point bottomLeft )
|
||||
: base( coordinate )
|
||||
{
|
||||
this[ 0 ] = topLeft;
|
||||
@@ -85,14 +80,14 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
: base( PlainCoordinate.StandardPlainCoordination )
|
||||
{
|
||||
vertexMat = new Vec4[4];
|
||||
@@ -104,15 +99,15 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
PlainCoordinate coordination,
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
PlainCoordinate coordination,
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
: base( coordination )
|
||||
{
|
||||
vertexMat = new Vec4[4];
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
@@ -48,16 +47,16 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
public Polygon5(
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y,
|
||||
float v4x,
|
||||
float v4y )
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y,
|
||||
float v4x,
|
||||
float v4y )
|
||||
: base( PlainCoordinate.StandardPlainCoordination )
|
||||
{
|
||||
vertexMat = new Vec4[5];
|
||||
@@ -69,17 +68,17 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
public Polygon5(
|
||||
PlainCoordinate coordination,
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y,
|
||||
float v4x,
|
||||
float v4y )
|
||||
PlainCoordinate coordination,
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y,
|
||||
float v4x,
|
||||
float v4y )
|
||||
: base( coordination )
|
||||
{
|
||||
vertexMat = new Vec4[5];
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
@@ -48,14 +47,14 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
public Polygon6(
|
||||
PlainCoordinate coordination,
|
||||
Vec2 vert0,
|
||||
Vec2 vert1,
|
||||
Vec2 vert2,
|
||||
Vec2 vert3,
|
||||
Vec2 vert4,
|
||||
Vec2 vert5,
|
||||
Vec2 vert6 )
|
||||
PlainCoordinate coordination,
|
||||
Vec2 vert0,
|
||||
Vec2 vert1,
|
||||
Vec2 vert2,
|
||||
Vec2 vert3,
|
||||
Vec2 vert4,
|
||||
Vec2 vert5,
|
||||
Vec2 vert6 )
|
||||
: base( coordination )
|
||||
{
|
||||
vertexMat = new Vec4[6];
|
||||
|
||||
@@ -39,14 +39,14 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
public Rectangle(
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
: base( v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y )
|
||||
{
|
||||
#if DEBUG
|
||||
@@ -59,15 +59,15 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
public Rectangle(
|
||||
PlainCoordinate coordination,
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
PlainCoordinate coordination,
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
: base( coordination, v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y )
|
||||
{
|
||||
#if DEBUG
|
||||
@@ -80,10 +80,14 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate movement to center
|
||||
/// Calculate movement to center
|
||||
/// </summary>
|
||||
/// <param _name="tick"> CurrentBlueprint time tick </param>
|
||||
/// <returns></returns>
|
||||
/// <param _label="tick">
|
||||
/// CurrentPipeline time tick
|
||||
/// </param>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
public virtual Vec3 MovCenter( uint tick )
|
||||
{
|
||||
return default( Vec3 );
|
||||
|
||||
@@ -35,20 +35,20 @@ using System.Numerics;
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
/// <summary>
|
||||
/// A square
|
||||
/// A square
|
||||
/// </summary>
|
||||
public class Square : Rectangle
|
||||
{
|
||||
|
||||
public Square(
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
: base( v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y )
|
||||
{
|
||||
if( true ) { }
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
|
||||
@@ -57,10 +56,10 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
public Triangle(
|
||||
PlainCoordinate coordination,
|
||||
Point vertex01,
|
||||
Point vertex02,
|
||||
Point vertex03 )
|
||||
PlainCoordinate coordination,
|
||||
Point vertex01,
|
||||
Point vertex02,
|
||||
Point vertex03 )
|
||||
: base( coordination )
|
||||
{
|
||||
this[ 0 ] = vertex01;
|
||||
@@ -68,13 +67,7 @@ namespace StgSharp.Geometries
|
||||
this[ 2 ] = vertex03;
|
||||
}
|
||||
|
||||
public Triangle(
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y )
|
||||
public Triangle( float v0x, float v0y, float v1x, float v1y, float v2x, float v2y )
|
||||
: base( PlainCoordinate.StandardPlainCoordination )
|
||||
{
|
||||
this[ 0 ] = new Point( v0x, v0y, 0 );
|
||||
@@ -83,13 +76,13 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
public Triangle(
|
||||
PlainCoordinate coordination,
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y )
|
||||
PlainCoordinate coordination,
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y )
|
||||
: base( coordination )
|
||||
{
|
||||
this[ 0 ] = new Point( v0x, v0y, 0 );
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Point.cs"
|
||||
// Project: StgSharp
|
||||
// Project: World
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="TriangulatedSurface.cs"
|
||||
// Project: StepVisualizer
|
||||
// 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.HighPerformance;
|
||||
using StgSharp.Math;
|
||||
using StgSharp.Math.HighPrecision;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Intrinsics;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class TriangulatedSurface
|
||||
{
|
||||
|
||||
private HashSet<(int begin,int end)> _sides;
|
||||
|
||||
private List<List<int>> _sideIndices;
|
||||
private List<int> _triangleIndices;
|
||||
private List<Vec3> _vertices;
|
||||
|
||||
public TriangulatedSurface()
|
||||
{
|
||||
_triangleIndices = new List<int>();
|
||||
_vertices = new List<Vec3>();
|
||||
_sides = new HashSet<(int,int)>();
|
||||
_sideIndices = new List<List<int>>();
|
||||
}
|
||||
|
||||
/**/
|
||||
public IEnumerable<List<int>> SideIndicesEnumeratble
|
||||
{
|
||||
get => _sideIndices ;
|
||||
}
|
||||
|
||||
/*
|
||||
public Triangle GetTriangle( int index )
|
||||
{
|
||||
Vec3HP v1,v2,v3;
|
||||
int t = index * 3;
|
||||
v1 = _vertices[ t + 0 ];
|
||||
v2 = _vertices[ t + 1 ];
|
||||
v3 = _vertices[ t + 2 ];
|
||||
return new Triangle( v1, v2, v3 );
|
||||
}
|
||||
/**/
|
||||
|
||||
public Span<Vec3> VertexSpan
|
||||
{
|
||||
get => CollectionsMarshal.AsSpan( _vertices );
|
||||
}
|
||||
|
||||
public Span<int> TriangleIndicesSpan
|
||||
{
|
||||
get => CollectionsMarshal.AsSpan( _triangleIndices );
|
||||
}
|
||||
|
||||
/**/
|
||||
public void AddIndicesByOrder( int v1, int v2, int v3 )
|
||||
{
|
||||
_triangleIndices.Add( v1 );
|
||||
_triangleIndices.Add( v2 );
|
||||
_triangleIndices.Add( v3 );
|
||||
if( !( _sides.Remove( (v1,v2) ) || _sides.Remove( (v2, v1) ) ) ) {
|
||||
_sides.Add( (v1, v2) );
|
||||
}
|
||||
if( !( _sides.Remove( (v2, v3) ) || _sides.Remove( (v3, v2) ) ) ) {
|
||||
_sides.Add( (v2, v3) );
|
||||
}
|
||||
if( !( _sides.Remove( (v3, v1) ) || _sides.Remove( (v1, v3) ) ) ) {
|
||||
_sides.Add( (v3, v1) );
|
||||
}
|
||||
}
|
||||
|
||||
public void AddVertexByOrder( Vec3 vertex )
|
||||
{
|
||||
_vertices.Add( vertex );
|
||||
}
|
||||
|
||||
public int TriangleCount()
|
||||
{
|
||||
return _triangleIndices.Count / 3;
|
||||
}
|
||||
|
||||
public void TrimExcess()
|
||||
{
|
||||
_triangleIndices.TrimExcess();
|
||||
_vertices.TrimExcess();
|
||||
Dictionary<int, int> side_dictionary = _sides.ToDictionary( x => x.begin, x => x.end );
|
||||
int begin = side_dictionary.First().Key;
|
||||
List<int> sideLoop = new List<int>( begin );
|
||||
_sideIndices.Add( sideLoop );
|
||||
while( side_dictionary.Count > 0 )
|
||||
{
|
||||
if( side_dictionary.Remove( begin, out begin ) )
|
||||
{
|
||||
sideLoop.Add( begin );
|
||||
} else
|
||||
{
|
||||
begin = side_dictionary.First().Key;
|
||||
sideLoop = new List<int>( begin );
|
||||
_sideIndices.Add( sideLoop );
|
||||
}
|
||||
}
|
||||
_sideIndices.TrimExcess();
|
||||
}
|
||||
|
||||
public int VertexCount()
|
||||
{
|
||||
return _vertices.Count;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user