daily update on 20241002 by nitload youmu, intrinsic function rebuild, syntax style arrange
This commit is contained in:
@@ -45,9 +45,7 @@ namespace StgSharp.Geometries
|
||||
private CoordinationBase localCoordination;
|
||||
private Matrix44 coordMat;
|
||||
|
||||
|
||||
public CoordinationBase(
|
||||
CoordinationBase localCoordination)
|
||||
public CoordinationBase( CoordinationBase localCoordination )
|
||||
{
|
||||
this.localCoordination = localCoordination;
|
||||
coordMat = new Matrix44();
|
||||
@@ -55,23 +53,23 @@ namespace StgSharp.Geometries
|
||||
|
||||
public virtual Point LocalOrigin
|
||||
{
|
||||
get => new Point(coordMat.colum3.XYZ);
|
||||
get => new Point( coordMat.colum3.XYZ );
|
||||
internal set => coordMat.colum3.XYZ = value.Coord;
|
||||
}
|
||||
|
||||
public virtual vec3d LocalX
|
||||
public virtual Vec3 LocalX
|
||||
{
|
||||
get => coordMat.colum0.XYZ;
|
||||
internal set => coordMat.colum0.XYZ = value;
|
||||
}
|
||||
|
||||
public virtual vec3d LocalY
|
||||
public virtual Vec3 LocalY
|
||||
{
|
||||
get => coordMat.colum1.XYZ;
|
||||
internal set => coordMat.colum1.XYZ = value;
|
||||
}
|
||||
|
||||
public virtual vec3d LocalZ
|
||||
public virtual Vec3 LocalZ
|
||||
{
|
||||
get => coordMat.colum2.XYZ;
|
||||
set => coordMat.colum2.XYZ = value;
|
||||
|
||||
@@ -41,23 +41,22 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
private static PlainCoordinate statndardPlainCoordination = new PlainCoordinate(
|
||||
null, new Point(0, 0, 0),
|
||||
new vec3d(1, 0, 0),
|
||||
new vec3d(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,
|
||||
vec3d xAxis,
|
||||
vec3d yAxis
|
||||
) : base(local)
|
||||
Vec3 xAxis,
|
||||
Vec3 yAxis )
|
||||
: base( local )
|
||||
{
|
||||
CoordMat = Matrix44.Unit;
|
||||
|
||||
CoordMat.colum0 = new vec4d(xAxis, 0);
|
||||
CoordMat.colum1 = new vec4d(yAxis, 0);
|
||||
CoordMat.colum2 = new vec4d(Linear.Normalize(Vec3d.Cross(xAxis, yAxis)), 0);
|
||||
CoordMat.colum0 = new Vec4( xAxis, 0 );
|
||||
CoordMat.colum1 = new Vec4( yAxis, 0 );
|
||||
CoordMat.colum2 = new Vec4(
|
||||
Linear.Normalize( Vec3.Cross( xAxis, yAxis ) ), 0 );
|
||||
|
||||
LocalOrigin = origin;
|
||||
}
|
||||
|
||||
@@ -40,11 +40,12 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
public SpaceCoordinate(
|
||||
CoordinationBase localCoordination, Point origin,
|
||||
vec3d xAxis, vec3d yAxis, vec3d zAxis
|
||||
) : base(localCoordination)
|
||||
{
|
||||
}
|
||||
CoordinationBase localCoordination,
|
||||
Point origin,
|
||||
Vec3 xAxis,
|
||||
Vec3 yAxis,
|
||||
Vec3 zAxis )
|
||||
: base( localCoordination ) { }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,20 +36,19 @@ namespace StgSharp.Geometries
|
||||
public unsafe class ToUpperDimensionException : Exception
|
||||
{
|
||||
|
||||
protected ToUpperDimensionException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
public ToUpperDimensionException()
|
||||
{
|
||||
}
|
||||
protected ToUpperDimensionException(
|
||||
SerializationInfo info,
|
||||
StreamingContext context )
|
||||
: base( info, context ) { }
|
||||
|
||||
public ToUpperDimensionException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
public ToUpperDimensionException() { }
|
||||
|
||||
public ToUpperDimensionException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
public ToUpperDimensionException( string message ) : base( message ) { }
|
||||
|
||||
public ToUpperDimensionException(
|
||||
string message,
|
||||
Exception innerException )
|
||||
: base( message, innerException ) { }
|
||||
|
||||
}
|
||||
|
||||
@@ -59,20 +58,17 @@ namespace StgSharp.Geometries
|
||||
public class UnusedVertexException : Exception
|
||||
{
|
||||
|
||||
protected UnusedVertexException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
public UnusedVertexException()
|
||||
{
|
||||
}
|
||||
protected UnusedVertexException(
|
||||
SerializationInfo info,
|
||||
StreamingContext context )
|
||||
: base( info, context ) { }
|
||||
|
||||
public UnusedVertexException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
public UnusedVertexException() { }
|
||||
|
||||
public UnusedVertexException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
public UnusedVertexException( string message ) : base( message ) { }
|
||||
|
||||
public UnusedVertexException( string message, Exception innerException )
|
||||
: base( message, innerException ) { }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,10 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate vec3d GeometryMotionDelegate(TimeSpanProvider timeSource, out float rotation);
|
||||
[UnmanagedFunctionPointer( CallingConvention.Cdecl )]
|
||||
public delegate Vec3 GeometryMotionDelegate(
|
||||
TimeSpanProvider timeSource,
|
||||
out float rotation );
|
||||
|
||||
public class GeometryMotion
|
||||
{
|
||||
@@ -54,69 +56,60 @@ namespace StgSharp.Geometries
|
||||
public unsafe GeometryMotion(
|
||||
bool isIncreament,
|
||||
TimeSpanProvider timeSource,
|
||||
GeometryMotionDelegate motionDelegate
|
||||
)
|
||||
GeometryMotionDelegate motionDelegate )
|
||||
{
|
||||
isIncrementMode = isIncreament;
|
||||
time = timeSource;
|
||||
if (motionDelegate == null)
|
||||
{
|
||||
handle = (IntPtr)(delegate*<TimeSpanProvider, out float, vec3d>)&defaultMotion;
|
||||
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);
|
||||
handle = Marshal.GetFunctionPointerForDelegate( motionDelegate );
|
||||
movement = motionDelegate;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
movement = motionDelegate;
|
||||
}
|
||||
|
||||
//sourceIsStatic = false;
|
||||
}
|
||||
|
||||
public bool IsIncrement
|
||||
{
|
||||
get => isIncrementMode;
|
||||
|
||||
}
|
||||
|
||||
public static GeometryMotion DefaultMotion
|
||||
{
|
||||
get => new GeometryMotion(true, null, null);
|
||||
get => new GeometryMotion( true, null, null );
|
||||
}
|
||||
|
||||
public unsafe void RunMotion(ref vec3d coord, ref float rotation)
|
||||
public unsafe void RunMotion( ref Vec3 coord, ref float rotation )
|
||||
{
|
||||
float rot;
|
||||
vec3d vec;
|
||||
if (sourceIsStatic)
|
||||
{
|
||||
vec = ((delegate* unmanaged[Cdecl]<TimeSpanProvider, out float, vec3d>)handle)(time, out rot);
|
||||
}
|
||||
else
|
||||
{
|
||||
vec = movement(time, out rot);
|
||||
Vec3 vec;
|
||||
if( sourceIsStatic ) {
|
||||
vec = ( ( delegate* unmanaged[Cdecl]<TimeSpanProvider, out float, Vec3> )handle )(
|
||||
time, out rot );
|
||||
} else {
|
||||
vec = movement( time, out rot );
|
||||
}
|
||||
|
||||
if (isIncrementMode)
|
||||
{
|
||||
if( isIncrementMode ) {
|
||||
coord += vec;
|
||||
rotation += rot;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
coord = vec;
|
||||
rotation = rot;
|
||||
}
|
||||
}
|
||||
|
||||
private static vec3d defaultMotion(TimeSpanProvider provider, out float rotation)
|
||||
private static Vec3 defaultMotion(
|
||||
TimeSpanProvider provider,
|
||||
out float rotation )
|
||||
{
|
||||
rotation = 0;
|
||||
return Vec3d.Zero;
|
||||
return Vec3.Zero;
|
||||
}
|
||||
|
||||
}//------------------------------- End of Class -------------------------------
|
||||
|
||||
@@ -42,46 +42,46 @@ namespace StgSharp.Math
|
||||
|
||||
internal const float DegToRad = 180 / Scaler.Pi;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Cos(Radius r)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static float Cos( Radius r )
|
||||
{
|
||||
return MathF.Cos(r._radius);
|
||||
return MathF.Cos( r._radius );
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Cos(Degree r)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static float Cos( Degree r )
|
||||
{
|
||||
return MathF.Cos(r._degree / DegToRad);
|
||||
return MathF.Cos( r._degree / DegToRad );
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Sin(Radius r)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static float Sin( Radius r )
|
||||
{
|
||||
return MathF.Sin(r._radius);
|
||||
return MathF.Sin( r._radius );
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Sin(Degree r)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static float Sin( Degree r )
|
||||
{
|
||||
return MathF.Sin(r._degree / DegToRad);
|
||||
return MathF.Sin( r._degree / DegToRad );
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Tan(Radius r)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static float Tan( Radius r )
|
||||
{
|
||||
return MathF.Tan(r._radius);
|
||||
return MathF.Tan( r._radius );
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Tan(Degree r)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static float Tan( Degree r )
|
||||
{
|
||||
return MathF.Tan(r._degree / DegToRad);
|
||||
return MathF.Tan( r._degree / DegToRad );
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Degree ToDegree(float value)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Degree ToDegree( float value )
|
||||
{
|
||||
return new Degree(value);
|
||||
return new Degree( value );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -91,14 +91,14 @@ namespace StgSharp.Math
|
||||
|
||||
internal float _degree;
|
||||
|
||||
internal Degree(float dgree)
|
||||
internal Degree( float dgree )
|
||||
{
|
||||
_degree = dgree;
|
||||
}
|
||||
|
||||
public static implicit operator Radius(Degree d)
|
||||
public static implicit operator Radius( Degree d )
|
||||
{
|
||||
return new Radius(d._degree / GeometryScaler.DegToRad);
|
||||
return new Radius( d._degree / GeometryScaler.DegToRad );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -108,70 +108,70 @@ namespace StgSharp.Math
|
||||
|
||||
internal float _radius;
|
||||
|
||||
[Obsolete("Unsafe, you may forget this is radius.", true)]
|
||||
[Obsolete( "Unsafe, you may forget this is radius.", true )]
|
||||
public Radius() { }
|
||||
|
||||
public Radius(float radius)
|
||||
public Radius( float radius )
|
||||
{
|
||||
_radius = radius;
|
||||
}
|
||||
|
||||
public static Radius Zero
|
||||
{
|
||||
get => new Radius(0);
|
||||
get => new Radius( 0 );
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Radius operator -(Radius r)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Radius operator -( Radius r )
|
||||
{
|
||||
return new Radius(-r._radius);
|
||||
return new Radius( -r._radius );
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Radius operator -(Radius left, Radius Right)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Radius operator -( Radius left, Radius Right )
|
||||
{
|
||||
return new Radius(left._radius - Right._radius);
|
||||
return new Radius( left._radius - Right._radius );
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(Radius left, Radius right)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static bool operator !=( Radius left, Radius right )
|
||||
{
|
||||
return left._radius != right._radius;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Radius operator *(Radius left, float right)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Radius operator *( Radius left, float right )
|
||||
{
|
||||
return new Radius(left._radius * right);
|
||||
return new Radius( left._radius * right );
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Radius operator /(Radius left, float right)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Radius operator /( Radius left, float right )
|
||||
{
|
||||
return new Radius(left._radius / right);
|
||||
return new Radius( left._radius / right );
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float operator /(Radius left, Radius right)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static float operator /( Radius left, Radius right )
|
||||
{
|
||||
return left._radius / right._radius;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Radius operator +(Radius left, Radius Right)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Radius operator +( Radius left, Radius Right )
|
||||
{
|
||||
return new Radius(left._radius + Right._radius);
|
||||
return new Radius( left._radius + Right._radius );
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(Radius left, Radius right)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static bool operator ==( Radius left, Radius right )
|
||||
{
|
||||
return left._radius == right._radius;
|
||||
}
|
||||
|
||||
public static implicit operator Degree(Radius r)
|
||||
public static implicit operator Degree( Radius r )
|
||||
{
|
||||
return new Degree((r._radius * 180) / Scaler.Pi);
|
||||
return new Degree( ( r._radius * 180 ) / Scaler.Pi );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,19 +42,23 @@ namespace StgSharp.Geometries
|
||||
public interface IGeometry
|
||||
{
|
||||
|
||||
public Point this[int index]
|
||||
public Point this[ int index ]
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#pragma warning disable CA1819
|
||||
public vec4d[] VertexStream
|
||||
#pragma warning restore CA1819
|
||||
#pragma warning disable CA1819
|
||||
public Vec4[] VertexStream
|
||||
#pragma warning restore CA1819
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public CoordinationBase Coordination
|
||||
{
|
||||
get;
|
||||
}
|
||||
public CoordinationBase Coordination { get; }
|
||||
|
||||
public int VertexCount
|
||||
{
|
||||
|
||||
@@ -36,9 +36,5 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public interface IGeomtryBuffer
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public interface IGeomtryBuffer { }
|
||||
}
|
||||
|
||||
@@ -45,24 +45,25 @@ namespace StgSharp.Geometries
|
||||
|
||||
public float Rotation
|
||||
{
|
||||
get { return GlobalBuffer.CoordAndRotationList[BufferId].W; }
|
||||
get { return GlobalBuffer.CoordAndRotationList[ BufferId ].W; }
|
||||
set
|
||||
{
|
||||
vec4d temp = GlobalBuffer.CoordAndRotationList[BufferId];
|
||||
Vec4 temp = GlobalBuffer.CoordAndRotationList[ BufferId ];
|
||||
temp.W = value;
|
||||
GlobalBuffer.CoordAndRotationList[BufferId] = temp;
|
||||
GlobalBuffer.CoordAndRotationList[ BufferId ] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
public float Scale
|
||||
{
|
||||
get { return GlobalBuffer.ScalingList[BufferId]; }
|
||||
set { GlobalBuffer.ScalingList[BufferId] = value; }
|
||||
get { return GlobalBuffer.ScalingList[ BufferId ]; }
|
||||
set { GlobalBuffer.ScalingList[ BufferId ] = value; }
|
||||
}
|
||||
|
||||
public GeometryMotion Motion
|
||||
{
|
||||
get; set;
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public IInstancingBuffer GlobalBuffer
|
||||
@@ -77,25 +78,25 @@ namespace StgSharp.Geometries
|
||||
internal set;
|
||||
}
|
||||
|
||||
public vec3d CenterPositionGlobal
|
||||
public Vec3 CenterPositionGlobal
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
|
||||
public vec3d Coord
|
||||
public Vec3 Coord
|
||||
{
|
||||
get { return GlobalBuffer.CoordAndRotationList[BufferId].XYZ; }
|
||||
set { GlobalBuffer.CoordAndRotationList[BufferId] = new vec4d(value.vec); }
|
||||
get { return GlobalBuffer.CoordAndRotationList[ BufferId ].XYZ; }
|
||||
set { GlobalBuffer.CoordAndRotationList[ BufferId ] = new Vec4(
|
||||
value.vec ); }
|
||||
}
|
||||
|
||||
public void Move()
|
||||
{
|
||||
(vec3d coord, float rotation) = (Coord, Rotation);
|
||||
Motion.RunMotion(ref coord, ref rotation);
|
||||
(Vec3 coord, float rotation) = (Coord, Rotation);
|
||||
Motion.RunMotion( ref coord, ref rotation );
|
||||
(Coord, Rotation) = (coord, rotation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,19 +39,35 @@ namespace StgSharp.Geometries
|
||||
public interface IInstancingBuffer
|
||||
{
|
||||
|
||||
public Span<vec4d> 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<vec4d> CoordAndRotationList { get; }
|
||||
|
||||
internal List<float> ScalingList { get; }
|
||||
internal List<Vec4> CoordAndRotationList
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
internal List<float> ScalingList
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[StructLayout( LayoutKind.Sequential )]
|
||||
public struct PartialPlainCoordinate
|
||||
{
|
||||
|
||||
@@ -49,40 +49,36 @@ namespace StgSharp.Geometries
|
||||
/// <summary>
|
||||
/// The origin of this coordinate.
|
||||
/// </summary>
|
||||
public vec3d origin;
|
||||
public Vec3 origin;
|
||||
|
||||
public PartialPlainCoordinate
|
||||
(
|
||||
vec3d origin,
|
||||
vec3d horiziontial,
|
||||
vec3d vertical
|
||||
)
|
||||
public PartialPlainCoordinate(
|
||||
Vec3 origin,
|
||||
Vec3 horiziontial,
|
||||
Vec3 vertical )
|
||||
{
|
||||
this.origin = origin;
|
||||
axis = new Matrix32();
|
||||
#if NET5_0_OR_GREATER
|
||||
Unsafe.SkipInit(out axis.mat);
|
||||
#endif
|
||||
#if NET5_0_OR_GREATER
|
||||
Unsafe.SkipInit( out axis.mat );
|
||||
#endif
|
||||
axis.colum0 = horiziontial;
|
||||
axis.colum1 = vertical;
|
||||
}
|
||||
|
||||
/// <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 vec3d axis_H => axis.colum0;
|
||||
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 vec3d axis_V => axis.colum1;
|
||||
public Vec3 axis_V => axis.colum1;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public vec3d GetRealLocate(vec2d raletiveLocation)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public Vec3 GetRealLocate( Vec2 raletiveLocation )
|
||||
{
|
||||
return origin + axis.VerticalVecMultiply(raletiveLocation);
|
||||
return origin + axis.VerticalVecMultiply( raletiveLocation );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,16 +34,14 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
public static unsafe class GeometryOperation
|
||||
{
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static vec3d DefaultMotion(int tick)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static Vec3 DefaultMotion( int tick )
|
||||
{
|
||||
return default(vec3d);
|
||||
return default( Vec3 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,39 +38,39 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
public interface IPlainEntity
|
||||
{
|
||||
|
||||
public vec2d CenterPosition { get; set; }
|
||||
public Vec2 CenterPosition
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool CollideWith(IPlainEntity entity);
|
||||
public bool CollideWith( IPlainEntity entity );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class PlainEntity : IPlainEntity
|
||||
{
|
||||
|
||||
private PlainGeometry _shape;
|
||||
|
||||
public PlainEntity(PlainGeometry shape)
|
||||
public PlainEntity( PlainGeometry shape )
|
||||
{
|
||||
_shape = shape;
|
||||
}
|
||||
|
||||
bool IPlainEntity.CollideWith(IPlainEntity entity)
|
||||
bool IPlainEntity.CollideWith( IPlainEntity entity )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
vec2d IPlainEntity.CenterPosition
|
||||
Vec2 IPlainEntity.CenterPosition
|
||||
{
|
||||
get => _shape.Coordination.LocalOrigin.Coord.XY;
|
||||
set => throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,15 +43,14 @@ namespace StgSharp.Geometries
|
||||
public class ParticleOnPlain : IInstancing, IPlainEntity
|
||||
{
|
||||
|
||||
public ParticleOnPlain(PlainInstancingBuffer<ParticleOnPlain> buffer)
|
||||
public ParticleOnPlain( PlainInstancingBuffer<ParticleOnPlain> buffer )
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException(paramName: nameof(buffer));
|
||||
if( buffer == null ) {
|
||||
throw new ArgumentNullException( paramName: nameof( buffer ) );
|
||||
}
|
||||
GlobalBuffer = buffer;
|
||||
BufferId = buffer.CreateInstanceID();
|
||||
((IInstancingBuffer)buffer).InstanceList.Add(this);
|
||||
( ( IInstancingBuffer )buffer ).InstanceList.Add( this );
|
||||
}
|
||||
|
||||
public GeometryMotion Motion
|
||||
@@ -72,21 +71,20 @@ namespace StgSharp.Geometries
|
||||
set;
|
||||
}
|
||||
|
||||
vec3d IInstancing.CenterPositionGlobal
|
||||
Vec3 IInstancing.CenterPositionGlobal
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
bool IPlainEntity.CollideWith(IPlainEntity entity)
|
||||
bool IPlainEntity.CollideWith( IPlainEntity entity )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
vec2d IPlainEntity.CenterPosition
|
||||
Vec2 IPlainEntity.CenterPosition
|
||||
{
|
||||
get => GlobalBuffer.CoordAndRotationList[BufferId].XY;
|
||||
get => GlobalBuffer.CoordAndRotationList[ BufferId ].XY;
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,33 +42,31 @@ namespace StgSharp.Geometries
|
||||
public abstract class PlainGeometry : IGeometry
|
||||
{
|
||||
|
||||
protected vec4d[] vertexMat;
|
||||
protected Vec4[] vertexMat;
|
||||
internal CoordinationBase coordinate;
|
||||
|
||||
|
||||
internal PlainGeometry(CoordinationBase coordination)
|
||||
internal PlainGeometry( CoordinationBase coordination )
|
||||
{
|
||||
coordinate = coordination;
|
||||
}
|
||||
|
||||
public Point this[int index]
|
||||
public Point this[ int index ]
|
||||
{
|
||||
get => new Point(vertexMat[index]);
|
||||
set => vertexMat[index].vec = value.coordVec;
|
||||
get => new Point( vertexMat[ index ] );
|
||||
set => vertexMat[ index ].vec = value.coordVec;
|
||||
}
|
||||
|
||||
|
||||
public int VertexCount => this.vertexMat.Length;
|
||||
|
||||
public abstract ReadOnlySpan<int> VertexIndices { get; }
|
||||
public abstract ReadOnlySpan<int> VertexIndices
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
#pragma warning disable CA1819
|
||||
public vec4d[] VertexStream => vertexMat;
|
||||
#pragma warning disable CA1819
|
||||
public Vec4[] VertexStream => vertexMat;
|
||||
|
||||
public CoordinationBase Coordination => this.coordinate;
|
||||
#pragma warning restore CA1819
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -44,26 +44,24 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class PlainInstancingBuffer<T> :
|
||||
IDisposable, IEnumerable<T>, IInstancingBuffer
|
||||
where T :
|
||||
IInstancing
|
||||
public class PlainInstancingBuffer<T> : IDisposable, IEnumerable<T>, IInstancingBuffer
|
||||
where T: IInstancing
|
||||
{
|
||||
|
||||
private bool disposedValue;
|
||||
|
||||
private CoordinatePlain globalCorrdinnate;
|
||||
private List<vec4d> coordList;
|
||||
private List<Vec4> coordList;
|
||||
private List<IInstancing> instanceList;
|
||||
private List<float> scalingList;
|
||||
private Mutex mutex;
|
||||
|
||||
public PlainInstancingBuffer()
|
||||
{
|
||||
coordList = new List<vec4d>(capacity: 100);
|
||||
instanceList = new List<IInstancing>(capacity: 100);
|
||||
scalingList = new List<float>(capacity: 100);
|
||||
coordArray = Array.Empty<vec4d>();
|
||||
coordList = new List<Vec4>( capacity: 100 );
|
||||
instanceList = new List<IInstancing>( capacity: 100 );
|
||||
scalingList = new List<float>( capacity: 100 );
|
||||
coordArray = Array.Empty<Vec4>();
|
||||
scaleArray = Array.Empty<float>();
|
||||
mutex = new Mutex();
|
||||
}
|
||||
@@ -73,7 +71,7 @@ namespace StgSharp.Geometries
|
||||
get => instanceList;
|
||||
}
|
||||
|
||||
public List<vec4d> CoordAndRotationList
|
||||
public List<Vec4> CoordAndRotationList
|
||||
{
|
||||
get => coordList;
|
||||
}
|
||||
@@ -83,25 +81,25 @@ namespace StgSharp.Geometries
|
||||
get => scalingList;
|
||||
}
|
||||
|
||||
public Span<vec4d> CoordAndRotationSpan
|
||||
public Span<Vec4> CoordAndRotationSpan
|
||||
{
|
||||
get
|
||||
{
|
||||
if (coordArray.Length != coordList.Capacity)
|
||||
{
|
||||
FieldInfo fieldInfo = typeof(List<vec4d>).
|
||||
GetField("_items", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (fieldInfo == null)
|
||||
{
|
||||
#pragma warning disable CA1065
|
||||
#pragma warning disable CA2201
|
||||
if( coordArray.Length != coordList.Capacity ) {
|
||||
FieldInfo fieldInfo = typeof( List<Vec4> ).
|
||||
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
|
||||
#pragma warning restore CA2201
|
||||
#pragma warning restore CA1065
|
||||
}
|
||||
coordArray = (vec4d[])fieldInfo.GetValue(coordList);
|
||||
coordArray = ( Vec4[] )fieldInfo.GetValue( coordList );
|
||||
}
|
||||
return new Span<vec4d>(coordArray, 0, coordList.Count);
|
||||
return new Span<Vec4>( coordArray, 0, coordList.Count );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,21 +107,21 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
get
|
||||
{
|
||||
if (scaleArray.Length != coordList.Capacity)
|
||||
{
|
||||
FieldInfo fieldInfo = typeof(List<float>).
|
||||
GetField("_items", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (fieldInfo == null)
|
||||
{
|
||||
#pragma warning disable CA1065
|
||||
#pragma warning disable CA2201
|
||||
if( scaleArray.Length != coordList.Capacity ) {
|
||||
FieldInfo fieldInfo = typeof( List<float> ).
|
||||
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
|
||||
#pragma warning restore CA2201
|
||||
#pragma warning restore CA1065
|
||||
}
|
||||
scaleArray = (float[])fieldInfo.GetValue(scalingList);
|
||||
scaleArray = ( float[] )fieldInfo.GetValue( scalingList );
|
||||
}
|
||||
return new Span<float>(scaleArray, 0, coordList.Count);
|
||||
return new Span<float>( scaleArray, 0, coordList.Count );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,8 +129,8 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
mutex.WaitOne();
|
||||
int ret = instanceList.Count;
|
||||
coordList.Add(new vec4d());
|
||||
scalingList.Add(0);
|
||||
coordList.Add( new Vec4() );
|
||||
scalingList.Add( 0 );
|
||||
mutex.ReleaseMutex();
|
||||
return ret;
|
||||
}
|
||||
@@ -144,55 +142,51 @@ namespace StgSharp.Geometries
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
Dispose( disposing: true );
|
||||
GC.SuppressFinalize( this );
|
||||
}
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
foreach (IInstancing item in instanceList)
|
||||
{
|
||||
yield return (T)item;
|
||||
foreach( IInstancing item in instanceList ) {
|
||||
yield return ( T )item;
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(T instance)
|
||||
public void Remove( T instance )
|
||||
{
|
||||
mutex.WaitOne();
|
||||
if (instance.GlobalBuffer != this)
|
||||
{
|
||||
if( instance.GlobalBuffer != this ) {
|
||||
throw new ArgumentException(
|
||||
message: "instance does not belong to current Particle Buffer",
|
||||
paramName: nameof(instance));
|
||||
paramName: nameof( instance ) );
|
||||
}
|
||||
int index = instance.BufferId;
|
||||
IInstancing temp = instanceList[instanceList.Count - 1];
|
||||
instanceList[instance.BufferId] = temp;
|
||||
IInstancing temp = instanceList[ instanceList.Count - 1 ];
|
||||
instanceList[ instance.BufferId ] = temp;
|
||||
temp.BufferId = instance.BufferId;
|
||||
|
||||
coordList[instance.BufferId] = coordList[coordList.Count - 1];
|
||||
scalingList[instance.BufferId] = scalingList[scalingList.Count - 1];
|
||||
coordList[ instance.BufferId ] = coordList[ coordList.Count - 1 ];
|
||||
scalingList[ instance.BufferId ] = scalingList[
|
||||
scalingList.Count - 1 ];
|
||||
|
||||
instanceList.RemoveAt(instanceList.Count - 1);
|
||||
coordList.RemoveAt(coordList.Count - 1);
|
||||
scalingList.RemoveAt(scalingList.Count - 1);
|
||||
instanceList.RemoveAt( instanceList.Count - 1 );
|
||||
coordList.RemoveAt( coordList.Count - 1 );
|
||||
scalingList.RemoveAt( scalingList.Count - 1 );
|
||||
mutex.ReleaseMutex();
|
||||
}
|
||||
|
||||
public void UpdateAllParticles()
|
||||
{
|
||||
foreach (IInstancing particle in instanceList)
|
||||
{
|
||||
foreach( IInstancing particle in instanceList ) {
|
||||
particle.Move();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
protected virtual void Dispose( bool disposing )
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if( !disposedValue ) {
|
||||
if( disposing ) {
|
||||
mutex.Dispose();
|
||||
}
|
||||
|
||||
@@ -205,21 +199,19 @@ namespace StgSharp.Geometries
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
foreach (IInstancing item in instanceList)
|
||||
{
|
||||
yield return (T)item;
|
||||
foreach( IInstancing item in instanceList ) {
|
||||
yield return ( T )item;
|
||||
}
|
||||
}
|
||||
|
||||
IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException();
|
||||
IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException(
|
||||
);
|
||||
|
||||
#region field of mem opt
|
||||
|
||||
vec4d[] coordArray;
|
||||
float[] scaleArray;
|
||||
|
||||
#endregion
|
||||
|
||||
private Vec4[] coordArray;
|
||||
private float[] scaleArray;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,52 +38,50 @@ namespace StgSharp.Geometries
|
||||
public class Parallelogram : Polygon4
|
||||
{
|
||||
|
||||
internal readonly Func<int, vec3d> movCenterOperation =
|
||||
new Func<int, vec3d>(GeometryOperation.DefaultMotion);
|
||||
internal readonly Func<int, Vec3> movCenterOperation =
|
||||
new Func<int, Vec3>( GeometryOperation.DefaultMotion );
|
||||
|
||||
internal Point center;
|
||||
|
||||
public Parallelogram(
|
||||
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
|
||||
)
|
||||
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
|
||||
)
|
||||
{
|
||||
InternalIO.InternalWriteLog("Init of geometry item failed, because four vertices cannot form a rectangle.", LogType.Warning);
|
||||
#if DEBUG
|
||||
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 );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
public Parallelogram(
|
||||
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
|
||||
)
|
||||
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
|
||||
)
|
||||
{
|
||||
InternalIO.InternalWriteLog("Init of geometry item failed, because four vertices cannot form a rectangle.", LogType.Warning);
|
||||
#if DEBUG
|
||||
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 );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,52 +38,54 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
internal readonly float d = -1;
|
||||
internal vec3d origin;
|
||||
internal Vec3 origin;
|
||||
|
||||
internal vec3d plainParameter;
|
||||
internal vec3d vec1;
|
||||
internal vec3d vec2;
|
||||
internal Vec3 plainParameter;
|
||||
internal Vec3 vec1;
|
||||
internal Vec3 vec2;
|
||||
|
||||
internal Plain(Vector4 origin, Vector4 p1, Vector4 p2)
|
||||
internal Plain( Vector4 origin, Vector4 p1, Vector4 p2 )
|
||||
{
|
||||
this.origin = new vec3d(origin);
|
||||
this.origin = new Vec3( origin );
|
||||
|
||||
vec1 = new vec3d(p1 - origin);
|
||||
vec2 = new vec3d(p2 - origin);
|
||||
vec1 = new Vec3( p1 - origin );
|
||||
vec2 = new Vec3( p2 - origin );
|
||||
}
|
||||
|
||||
public Plain(vec3d o, vec3d v1, vec3d v2)
|
||||
public Plain( Vec3 o, Vec3 v1, Vec3 v2 )
|
||||
{
|
||||
this.origin = o;
|
||||
this.vec1 = v1 - (v2 * (v1.Y / v2.Y)); //计算平面在xz平面上的方向投影
|
||||
this.vec2 = v2 - (vec1 * (v2.X / v1.X)); //计算平面在yz平面上的方向投影
|
||||
this.vec1 = v1 - ( v2 * ( v1.Y / v2.Y ) ); //计算平面在xz平面上的方向投影
|
||||
this.vec2 = v2 - ( vec1 * ( v2.X / v1.X ) ); //计算平面在yz平面上的方向投影
|
||||
|
||||
//|origin|-k1*|vec1|-k2*|vec2|计算plainParameter.Z;
|
||||
plainParameter.Z = origin.Z - (vec1.Z * (origin.X / vec1.X)) - (vec2.Z * (origin.Y / vec2.Y));
|
||||
plainParameter.Z = origin.Z - ( vec1.Z * ( origin.X / vec1.X ) ) - ( vec2.Z * ( origin.Y / vec2.Y ) );
|
||||
|
||||
//根据plainParameter.Z和对应的方向矢量计算plainParameter.X和plainParameter.Y
|
||||
plainParameter.X = vec1.X * (vec1.Z / plainParameter.Z);
|
||||
plainParameter.Y = vec2.Y * (vec2.Z / plainParameter.Z);
|
||||
plainParameter.X = vec1.X * ( vec1.Z / plainParameter.Z );
|
||||
plainParameter.Y = vec2.Y * ( vec2.Z / plainParameter.Z );
|
||||
|
||||
plainParameter.X = 1 / plainParameter.X;
|
||||
plainParameter.Y = 1 / plainParameter.Y;
|
||||
plainParameter.Z = 1 / plainParameter.Z;
|
||||
}
|
||||
|
||||
public Plain(Point p1, Point p2, Point p3)
|
||||
public Plain( Point p1, Point p2, Point p3 )
|
||||
{
|
||||
vec3d origin = p1.Coord;
|
||||
vec3d v1 = p2.Coord - origin;
|
||||
vec3d v2 = p3.Coord - origin;
|
||||
Vec3 origin = p1.Coord;
|
||||
Vec3 v1 = p2.Coord - origin;
|
||||
Vec3 v2 = p3.Coord - origin;
|
||||
|
||||
|
||||
vec1 = v1 - (v2 * (v1.Y / v2.Y)); //计算平面在xz平面上的方向投影
|
||||
vec2 = v2 - (vec1 * (v2.X / v1.X)); //计算平面在yz平面上的方向投影
|
||||
vec1 = v1 - ( v2 * ( v1.Y / v2.Y ) ); //计算平面在xz平面上的方向投影
|
||||
vec2 = v2 - ( vec1 * ( v2.X / v1.X ) ); //计算平面在yz平面上的方向投影
|
||||
|
||||
//|origin|-k1*|vec1|-k2*|vec2|计算plainParameter.Z;
|
||||
plainParameter.Z = origin.Z - (vec1.Z * (origin.X / vec1.X)) - (vec2.Z * (origin.Y / vec2.Y));
|
||||
plainParameter.Z = origin.Z - ( vec1.Z * ( origin.X / vec1.X ) ) - ( vec2.Z * ( origin.Y / vec2.Y ) );
|
||||
|
||||
//根据plainParameter.Z和对应的方向矢量计算plainParameter.X和plainParameter.Y
|
||||
plainParameter.X = vec1.X * (vec1.Z / plainParameter.Z);
|
||||
plainParameter.Y = vec2.Y * (vec2.Z / plainParameter.Z);
|
||||
plainParameter.X = vec1.X * ( vec1.Z / plainParameter.Z );
|
||||
plainParameter.Y = vec2.Y * ( vec2.Z / plainParameter.Z );
|
||||
|
||||
plainParameter.X = 1 / plainParameter.X;
|
||||
plainParameter.Y = 1 / plainParameter.Y;
|
||||
|
||||
@@ -41,17 +41,17 @@ namespace StgSharp.Geometries
|
||||
|
||||
protected static int[] Indices = [0, 1, 2, 0, 2, 3];
|
||||
|
||||
internal Polygon4() : base(PlainCoordinate.StandardPlainCoordination)
|
||||
internal Polygon4()
|
||||
: base( PlainCoordinate.StandardPlainCoordination )
|
||||
{
|
||||
vertexMat = new vec4d[4];
|
||||
vertexMat = new Vec4[4];
|
||||
}
|
||||
|
||||
internal Polygon4(vec4d[] rawCoord) :
|
||||
base(PlainCoordinate.StandardPlainCoordination)
|
||||
internal Polygon4( Vec4[] rawCoord )
|
||||
: base( PlainCoordinate.StandardPlainCoordination )
|
||||
{
|
||||
if (rawCoord.Length != 4)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(rawCoord));
|
||||
if( rawCoord.Length != 4 ) {
|
||||
throw new ArgumentOutOfRangeException( nameof( rawCoord ) );
|
||||
}
|
||||
vertexMat = rawCoord;
|
||||
}
|
||||
@@ -60,61 +60,67 @@ namespace StgSharp.Geometries
|
||||
Point topLeft,
|
||||
Point topRight,
|
||||
Point bottomRight,
|
||||
Point bottomLeft
|
||||
) : base(PlainCoordinate.StandardPlainCoordination)
|
||||
Point bottomLeft )
|
||||
: base( PlainCoordinate.StandardPlainCoordination )
|
||||
{
|
||||
this[0] = topLeft;
|
||||
this[1] = topRight;
|
||||
this[2] = bottomRight;
|
||||
this[3] = bottomLeft;
|
||||
|
||||
this[ 0 ] = topLeft;
|
||||
this[ 1 ] = topRight;
|
||||
this[ 2 ] = bottomRight;
|
||||
this[ 3 ] = bottomLeft;
|
||||
}
|
||||
|
||||
|
||||
public Polygon4(CoordinationBase coordinate,
|
||||
public Polygon4(
|
||||
CoordinationBase coordinate,
|
||||
PlainCoordinate coordination,
|
||||
Point topLeft,
|
||||
Point topRight,
|
||||
Point bottomRight,
|
||||
Point bottomLeft
|
||||
) : base(coordinate)
|
||||
Point bottomLeft )
|
||||
: base( coordinate )
|
||||
{
|
||||
this[0] = topLeft;
|
||||
this[1] = topRight;
|
||||
this[2] = bottomRight;
|
||||
this[3] = bottomLeft;
|
||||
|
||||
this[ 0 ] = topLeft;
|
||||
this[ 1 ] = topRight;
|
||||
this[ 2 ] = bottomRight;
|
||||
this[ 3 ] = bottomLeft;
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y
|
||||
) : base(PlainCoordinate.StandardPlainCoordination)
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
: base( PlainCoordinate.StandardPlainCoordination )
|
||||
{
|
||||
vertexMat = new vec4d[4];
|
||||
vertexMat = new Vec4[4];
|
||||
|
||||
this[0] = new Point(v0x, v0y, 0);
|
||||
this[1] = new Point(v1x, v1y, 0);
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
this[3] = new Point(v3x, v3y, 0);
|
||||
this[ 0 ] = new Point( v0x, v0y, 0 );
|
||||
this[ 1 ] = new Point( v1x, v1y, 0 );
|
||||
this[ 2 ] = new Point( v2x, v2y, 0 );
|
||||
this[ 3 ] = new Point( v3x, v3y, 0 );
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
PlainCoordinate coordination,
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y
|
||||
) : base(coordination)
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y,
|
||||
float v3x,
|
||||
float v3y )
|
||||
: base( coordination )
|
||||
{
|
||||
vertexMat = new vec4d[4];
|
||||
vertexMat = new Vec4[4];
|
||||
|
||||
this[0] = new Point(v0x, v0y, 0);
|
||||
this[1] = new Point(v1x, v1y, 0);
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
this[3] = new Point(v3x, v3y, 0);
|
||||
this[ 0 ] = new Point( v0x, v0y, 0 );
|
||||
this[ 1 ] = new Point( v1x, v1y, 0 );
|
||||
this[ 2 ] = new Point( v2x, v2y, 0 );
|
||||
this[ 3 ] = new Point( v3x, v3y, 0 );
|
||||
}
|
||||
|
||||
public override ReadOnlySpan<int> VertexIndices => Indices;
|
||||
|
||||
@@ -41,42 +41,53 @@ namespace StgSharp.Geometries
|
||||
|
||||
internal static int[] Indices = [0, 1, 2, 0, 2, 3, 0, 3, 4];
|
||||
|
||||
public unsafe Polygon5() : base(PlainCoordinate.StandardPlainCoordination)
|
||||
public unsafe Polygon5()
|
||||
: base( PlainCoordinate.StandardPlainCoordination )
|
||||
{
|
||||
vertexMat = new vec4d[5];
|
||||
vertexMat = new Vec4[5];
|
||||
}
|
||||
|
||||
public Polygon5(
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y,
|
||||
float v4x, float v4y
|
||||
) : base(PlainCoordinate.StandardPlainCoordination)
|
||||
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 vec4d[5];
|
||||
this[0] = new Point(v0x, v0y, 0);
|
||||
this[1] = new Point(v1x, v1y, 0);
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
this[3] = new Point(v3x, v3y, 0);
|
||||
this[4] = new Point(v4x, v4y, 0);
|
||||
vertexMat = new Vec4[5];
|
||||
this[ 0 ] = new Point( v0x, v0y, 0 );
|
||||
this[ 1 ] = new Point( v1x, v1y, 0 );
|
||||
this[ 2 ] = new Point( v2x, v2y, 0 );
|
||||
this[ 3 ] = new Point( v3x, v3y, 0 );
|
||||
this[ 4 ] = new Point( v4x, v4y, 0 );
|
||||
}
|
||||
|
||||
public Polygon5(
|
||||
PlainCoordinate coordination,
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y,
|
||||
float v4x, float v4y
|
||||
) : base(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 vec4d[5];
|
||||
this[0] = new Point(v0x, v0y, 0);
|
||||
this[1] = new Point(v1x, v1y, 0);
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
this[3] = new Point(v3x, v3y, 0);
|
||||
this[4] = new Point(v4x, v4y, 0);
|
||||
vertexMat = new Vec4[5];
|
||||
this[ 0 ] = new Point( v0x, v0y, 0 );
|
||||
this[ 1 ] = new Point( v1x, v1y, 0 );
|
||||
this[ 2 ] = new Point( v2x, v2y, 0 );
|
||||
this[ 3 ] = new Point( v3x, v3y, 0 );
|
||||
this[ 4 ] = new Point( v4x, v4y, 0 );
|
||||
}
|
||||
|
||||
public override ReadOnlySpan<int> VertexIndices => Indices;
|
||||
|
||||
@@ -41,30 +41,31 @@ namespace StgSharp.Geometries
|
||||
|
||||
internal static int[] Indices = [0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5];
|
||||
|
||||
public Polygon6() : base(PlainCoordinate.StandardPlainCoordination)
|
||||
public Polygon6()
|
||||
: base( PlainCoordinate.StandardPlainCoordination )
|
||||
{
|
||||
vertexMat = new vec4d[6];
|
||||
vertexMat = new Vec4[6];
|
||||
}
|
||||
|
||||
public Polygon6(
|
||||
PlainCoordinate coordination,
|
||||
vec2d vert0,
|
||||
vec2d vert1,
|
||||
vec2d vert2,
|
||||
vec2d vert3,
|
||||
vec2d vert4,
|
||||
vec2d vert5,
|
||||
vec2d vert6
|
||||
) : base(coordination)
|
||||
Vec2 vert0,
|
||||
Vec2 vert1,
|
||||
Vec2 vert2,
|
||||
Vec2 vert3,
|
||||
Vec2 vert4,
|
||||
Vec2 vert5,
|
||||
Vec2 vert6 )
|
||||
: base( coordination )
|
||||
{
|
||||
vertexMat = new vec4d[6];
|
||||
vertexMat[0].vec = vert0.vec;
|
||||
vertexMat[1].vec = vert1.vec;
|
||||
vertexMat[2].vec = vert2.vec;
|
||||
vertexMat[3].vec = vert3.vec;
|
||||
vertexMat[4].vec = vert4.vec;
|
||||
vertexMat[5].vec = vert5.vec;
|
||||
vertexMat[6].vec = vert6.vec;
|
||||
vertexMat = new Vec4[6];
|
||||
vertexMat[ 0 ].vec = vert0.vec;
|
||||
vertexMat[ 1 ].vec = vert1.vec;
|
||||
vertexMat[ 2 ].vec = vert2.vec;
|
||||
vertexMat[ 3 ].vec = vert3.vec;
|
||||
vertexMat[ 4 ].vec = vert4.vec;
|
||||
vertexMat[ 5 ].vec = vert5.vec;
|
||||
vertexMat[ 6 ].vec = vert6.vec;
|
||||
}
|
||||
|
||||
public override ReadOnlySpan<int> VertexIndices => Indices;
|
||||
|
||||
@@ -38,59 +38,54 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
public Rectangle(
|
||||
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
|
||||
)
|
||||
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
|
||||
vec2d side0 = (this[0].Coord - this[1].Coord).XY;
|
||||
vec2d side1 = (this[2].Coord - this[1].Coord).XY;
|
||||
if (side0.Cross(side1) == 0)
|
||||
{
|
||||
#if DEBUG
|
||||
Vec2 side0 = ( this[ 0 ].Coord - this[ 1 ].Coord ).XY;
|
||||
Vec2 side1 = ( this[ 2 ].Coord - this[ 1 ].Coord ).XY;
|
||||
if( side0.Cross( side1 ) == 0 ) {
|
||||
throw new ArgumentException();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public Rectangle(
|
||||
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
|
||||
)
|
||||
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
|
||||
vec2d side0 = (this[0].Coord - this[1].Coord).XY;
|
||||
vec2d side1 = (this[2].Coord - this[1].Coord).XY;
|
||||
if (side0.Cross(side1) == 0)
|
||||
{
|
||||
#if DEBUG
|
||||
Vec2 side0 = ( this[ 0 ].Coord - this[ 1 ].Coord ).XY;
|
||||
Vec2 side1 = ( this[ 2 ].Coord - this[ 1 ].Coord ).XY;
|
||||
if( side0.Cross( side1 ) == 0 ) {
|
||||
throw new ArgumentException();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate movement to center
|
||||
/// </summary>
|
||||
/// <param name="tick">CurrentBlueprint time tick</param>
|
||||
/// <param name="tick"> CurrentBlueprint time tick </param>
|
||||
/// <returns></returns>
|
||||
public virtual vec3d MovCenter(uint tick)
|
||||
public virtual Vec3 MovCenter( uint tick )
|
||||
{
|
||||
return default(vec3d);
|
||||
return default( Vec3 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ using System.Numerics;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A square
|
||||
/// </summary>
|
||||
@@ -42,21 +41,18 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
public Square(
|
||||
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)
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
if( true ) { }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -37,60 +37,64 @@ using System.Numerics;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
|
||||
public unsafe class Triangle : PlainGeometry
|
||||
{
|
||||
|
||||
internal static int[] Indices = [0, 1, 2];
|
||||
|
||||
public Triangle() : base(PlainCoordinate.StandardPlainCoordination)
|
||||
public Triangle()
|
||||
: base( PlainCoordinate.StandardPlainCoordination )
|
||||
{
|
||||
vertexMat = new vec4d[3];
|
||||
vertexMat = new Vec4[3];
|
||||
}
|
||||
|
||||
public Triangle( Point vertex01, Point vertex02, Point vertex03 )
|
||||
: base( PlainCoordinate.StandardPlainCoordination )
|
||||
{
|
||||
this[ 0 ] = vertex01;
|
||||
this[ 1 ] = vertex02;
|
||||
this[ 2 ] = vertex03;
|
||||
}
|
||||
|
||||
public Triangle(
|
||||
PlainCoordinate coordination,
|
||||
Point vertex01,
|
||||
Point vertex02,
|
||||
Point vertex03
|
||||
) : base(PlainCoordinate.StandardPlainCoordination)
|
||||
Point vertex03 )
|
||||
: base( coordination )
|
||||
{
|
||||
this[0] = vertex01;
|
||||
this[1] = vertex02;
|
||||
this[2] = vertex03;
|
||||
}
|
||||
|
||||
public Triangle(PlainCoordinate coordination,
|
||||
Point vertex01,
|
||||
Point vertex02,
|
||||
Point vertex03
|
||||
) : base(coordination)
|
||||
{
|
||||
this[0] = vertex01;
|
||||
this[1] = vertex02;
|
||||
this[2] = vertex03;
|
||||
this[ 0 ] = vertex01;
|
||||
this[ 1 ] = vertex02;
|
||||
this[ 2 ] = vertex03;
|
||||
}
|
||||
|
||||
public Triangle(
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y
|
||||
) : base(PlainCoordinate.StandardPlainCoordination)
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y )
|
||||
: base( PlainCoordinate.StandardPlainCoordination )
|
||||
{
|
||||
this[0] = new Point(v0x, v0y, 0);
|
||||
this[1] = new Point(v1x, v1y, 0);
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
this[ 0 ] = new Point( v0x, v0y, 0 );
|
||||
this[ 1 ] = new Point( v1x, v1y, 0 );
|
||||
this[ 2 ] = new Point( v2x, v2y, 0 );
|
||||
}
|
||||
|
||||
public Triangle(PlainCoordinate coordination,
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y
|
||||
) : base(coordination)
|
||||
public Triangle(
|
||||
PlainCoordinate coordination,
|
||||
float v0x,
|
||||
float v0y,
|
||||
float v1x,
|
||||
float v1y,
|
||||
float v2x,
|
||||
float v2y )
|
||||
: base( coordination )
|
||||
{
|
||||
this[0] = new Point(v0x, v0y, 0);
|
||||
this[1] = new Point(v1x, v1y, 0);
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
this[ 0 ] = new Point( v0x, v0y, 0 );
|
||||
this[ 1 ] = new Point( v1x, v1y, 0 );
|
||||
this[ 2 ] = new Point( v2x, v2y, 0 );
|
||||
}
|
||||
|
||||
public override ReadOnlySpan<int> VertexIndices => Indices;
|
||||
|
||||
@@ -38,37 +38,39 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16)]
|
||||
[StructLayout( LayoutKind.Explicit, Size = 16 )]
|
||||
public struct Point
|
||||
{
|
||||
|
||||
[FieldOffset(0)] private vec3d coord;
|
||||
[FieldOffset(0)] internal Vector4 coordVec;
|
||||
[FieldOffset( 0 )] private Vec3 coord;
|
||||
[FieldOffset( 0 )] internal Vector4 coordVec;
|
||||
|
||||
internal Point(vec4d vector)
|
||||
internal Point( Vec4 vector )
|
||||
{
|
||||
coordVec = vector.vec;
|
||||
coordVec.W = 1;
|
||||
}
|
||||
|
||||
public Point(vec3d coord)
|
||||
public Point( Vec3 coord )
|
||||
{
|
||||
Coord = coord;
|
||||
coordVec.W = 1;
|
||||
}
|
||||
|
||||
public Point(float x, float y, float z)
|
||||
public Point( float x, float y, float z )
|
||||
{
|
||||
coordVec = new Vector4(x, y, z, 1);
|
||||
coordVec = new Vector4( x, y, z, 1 );
|
||||
}
|
||||
|
||||
public vec3d Coord
|
||||
public Vec3 Coord
|
||||
{
|
||||
get => coord;
|
||||
set { coord = value; coordVec.W = 1; }
|
||||
set
|
||||
{
|
||||
coord = value;
|
||||
coordVec.W = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,5 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries.SpaceGeometry
|
||||
{
|
||||
internal class Class1
|
||||
{
|
||||
}
|
||||
internal class Class1 { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user