daily update on 20240828 by nitload youmu, autotexture added
This commit is contained in:
@@ -37,6 +37,7 @@ namespace StgSharp.Geometries
|
||||
|
||||
public static unsafe class GeometryOperation
|
||||
{
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static vec3d DefaultMotion(int tick)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,34 @@
|
||||
using StgSharp.Math;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="IPlainEntity.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;
|
||||
@@ -11,22 +41,19 @@ namespace StgSharp.Geometries
|
||||
|
||||
public interface IPlainEntity
|
||||
{
|
||||
|
||||
public vec2d CenterPosition { get; set; }
|
||||
|
||||
public bool CollideWith(IPlainEntity entity);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class PlainEntity:IPlainEntity
|
||||
public class PlainEntity : IPlainEntity
|
||||
{
|
||||
private PlainGeometry _shape;
|
||||
|
||||
vec2d IPlainEntity.CenterPosition
|
||||
{
|
||||
get => _shape.Coordination.LocalOrigin.Coord.XY;
|
||||
set => throw new InvalidOperationException();
|
||||
}
|
||||
private PlainGeometry _shape;
|
||||
|
||||
public PlainEntity(PlainGeometry shape)
|
||||
{
|
||||
@@ -37,6 +64,13 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
vec2d IPlainEntity.CenterPosition
|
||||
{
|
||||
get => _shape.Coordination.LocalOrigin.Coord.XY;
|
||||
set => throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="IInstancing.cs"
|
||||
// file="ParticleOnPlain.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -54,7 +54,7 @@ namespace StgSharp.Geometries
|
||||
((IInstancingBuffer)buffer).InstanceList.Add(this);
|
||||
}
|
||||
|
||||
public int BufferId
|
||||
public GeometryMotion Motion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
@@ -65,9 +65,10 @@ namespace StgSharp.Geometries
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public GeometryMotion Motion
|
||||
{
|
||||
get;
|
||||
|
||||
public int BufferId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
@@ -77,16 +78,17 @@ namespace StgSharp.Geometries
|
||||
set;
|
||||
}
|
||||
|
||||
vec2d IPlainEntity.CenterPosition
|
||||
{
|
||||
get => GlobalBuffer.CoordAndRotationList[BufferId].XY;
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
bool IPlainEntity.CollideWith(IPlainEntity entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
vec2d IPlainEntity.CenterPosition
|
||||
{
|
||||
get => GlobalBuffer.CoordAndRotationList[BufferId].XY;
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,11 @@ namespace StgSharp.Geometries
|
||||
/// </summary>
|
||||
public abstract class PlainGeometry : IGeometry
|
||||
{
|
||||
|
||||
protected vec4d[] vertexMat;
|
||||
internal CoordinationBase coordinate;
|
||||
|
||||
|
||||
internal PlainGeometry(CoordinationBase coordination)
|
||||
{
|
||||
coordinate = coordination;
|
||||
|
||||
@@ -44,30 +44,24 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class PlainInstancingBuffer<T> :
|
||||
IDisposable,IEnumerable<T>, IInstancingBuffer
|
||||
where T :
|
||||
public class PlainInstancingBuffer<T> :
|
||||
IDisposable, IEnumerable<T>, IInstancingBuffer
|
||||
where T :
|
||||
IInstancing
|
||||
{
|
||||
|
||||
private bool disposedValue;
|
||||
|
||||
private CoordinatePlain globalCorrdinnate;
|
||||
private List<vec4d> coordList;
|
||||
private List<IInstancing> instanceList;
|
||||
private List<float> scalingList;
|
||||
private Mutex mutex;
|
||||
private bool disposedValue;
|
||||
|
||||
#region field of mem opt
|
||||
|
||||
vec4d[] coordArray;
|
||||
float[] scaleArray;
|
||||
|
||||
#endregion
|
||||
|
||||
public PlainInstancingBuffer()
|
||||
{
|
||||
coordList = new List<vec4d>(capacity: 100);
|
||||
instanceList = new List<IInstancing>(capacity:100);
|
||||
instanceList = new List<IInstancing>(capacity: 100);
|
||||
scalingList = new List<float>(capacity: 100);
|
||||
coordArray = Array.Empty<vec4d>();
|
||||
scaleArray = Array.Empty<float>();
|
||||
@@ -133,8 +127,6 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
}
|
||||
|
||||
IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException();
|
||||
|
||||
public int CreateInstanceID()
|
||||
{
|
||||
mutex.WaitOne();
|
||||
@@ -145,13 +137,32 @@ namespace StgSharp.Geometries
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ~PlainInstancingBuffer()
|
||||
// {
|
||||
// Dispose(disposing: false);
|
||||
// }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
foreach (IInstancing item in instanceList)
|
||||
{
|
||||
yield return (T)item;
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(T instance)
|
||||
{
|
||||
mutex.WaitOne();
|
||||
if (instance.GlobalBuffer != this)
|
||||
{
|
||||
throw new ArgumentException(
|
||||
message:"instance does not belong to current Particle Buffer",
|
||||
message: "instance does not belong to current Particle Buffer",
|
||||
paramName: nameof(instance));
|
||||
}
|
||||
int index = instance.BufferId;
|
||||
@@ -170,7 +181,7 @@ namespace StgSharp.Geometries
|
||||
|
||||
public void UpdateAllParticles()
|
||||
{
|
||||
foreach (var particle in instanceList)
|
||||
foreach (IInstancing particle in instanceList)
|
||||
{
|
||||
particle.Move();
|
||||
}
|
||||
@@ -192,31 +203,23 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
}
|
||||
|
||||
// ~PlainInstancingBuffer()
|
||||
// {
|
||||
// Dispose(disposing: false);
|
||||
// }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
foreach (var item in instanceList)
|
||||
{
|
||||
yield return (T)item;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
foreach (var item in instanceList)
|
||||
foreach (IInstancing item in instanceList)
|
||||
{
|
||||
yield return (T)item;
|
||||
}
|
||||
}
|
||||
|
||||
IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException();
|
||||
|
||||
#region field of mem opt
|
||||
|
||||
vec4d[] coordArray;
|
||||
float[] scaleArray;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,14 +38,15 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
public class Polygon4 : PlainGeometry
|
||||
{
|
||||
|
||||
protected static int[] Indices = [0, 1, 2, 0, 2, 3];
|
||||
|
||||
internal Polygon4():base(PlainCoordinate.StandardPlainCoordination)
|
||||
internal Polygon4() : base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
vertexMat = new vec4d[4];
|
||||
}
|
||||
|
||||
internal Polygon4(vec4d[] rawCoord):
|
||||
internal Polygon4(vec4d[] rawCoord) :
|
||||
base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
if (rawCoord.Length != 4)
|
||||
@@ -60,7 +61,7 @@ namespace StgSharp.Geometries
|
||||
Point topRight,
|
||||
Point bottomRight,
|
||||
Point bottomLeft
|
||||
):base(PlainCoordinate.StandardPlainCoordination)
|
||||
) : base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
this[0] = topLeft;
|
||||
this[1] = topRight;
|
||||
@@ -69,21 +70,6 @@ namespace StgSharp.Geometries
|
||||
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y
|
||||
):base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
vertexMat = new vec4d[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);
|
||||
}
|
||||
|
||||
|
||||
public Polygon4(CoordinationBase coordinate,
|
||||
PlainCoordinate coordination,
|
||||
@@ -100,6 +86,21 @@ namespace StgSharp.Geometries
|
||||
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y
|
||||
) : base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
vertexMat = new vec4d[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);
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
PlainCoordinate coordination,
|
||||
float v0x, float v0y,
|
||||
|
||||
@@ -39,7 +39,9 @@ namespace StgSharp.Geometries
|
||||
public unsafe class Polygon5 : PlainGeometry
|
||||
{
|
||||
|
||||
public unsafe Polygon5():base(PlainCoordinate.StandardPlainCoordination)
|
||||
internal static int[] Indices = [0, 1, 2, 0, 2, 3, 0, 3, 4];
|
||||
|
||||
public unsafe Polygon5() : base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
vertexMat = new vec4d[5];
|
||||
}
|
||||
@@ -50,7 +52,7 @@ namespace StgSharp.Geometries
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y,
|
||||
float v4x, float v4y
|
||||
):base(PlainCoordinate.StandardPlainCoordination)
|
||||
) : base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
vertexMat = new vec4d[5];
|
||||
this[0] = new Point(v0x, v0y, 0);
|
||||
@@ -67,7 +69,7 @@ namespace StgSharp.Geometries
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y,
|
||||
float v4x, float v4y
|
||||
):base(coordination)
|
||||
) : base(coordination)
|
||||
{
|
||||
vertexMat = new vec4d[5];
|
||||
this[0] = new Point(v0x, v0y, 0);
|
||||
@@ -77,8 +79,7 @@ namespace StgSharp.Geometries
|
||||
this[4] = new Point(v4x, v4y, 0);
|
||||
}
|
||||
|
||||
internal static int[] Indices = [ 0, 1, 2, 0, 2, 3, 0, 3, 4 ];
|
||||
|
||||
public override ReadOnlySpan<int> VertexIndices => Indices;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,10 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
public class Polygon6 : PlainGeometry
|
||||
{
|
||||
public Polygon6():base(PlainCoordinate.StandardPlainCoordination)
|
||||
|
||||
internal static int[] Indices = [0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5];
|
||||
|
||||
public Polygon6() : base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
vertexMat = new vec4d[6];
|
||||
}
|
||||
@@ -64,8 +67,7 @@ namespace StgSharp.Geometries
|
||||
vertexMat[6].vec = vert6.vec;
|
||||
}
|
||||
|
||||
internal static int[] Indices = [ 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5 ];
|
||||
|
||||
public override ReadOnlySpan<int> VertexIndices => Indices;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -86,14 +86,12 @@ namespace StgSharp.Geometries
|
||||
/// <summary>
|
||||
/// Calculate movement to center
|
||||
/// </summary>
|
||||
/// <param name="tick">Current time tick</param>
|
||||
/// <param name="tick">CurrentBlueprint time tick</param>
|
||||
/// <returns></returns>
|
||||
public virtual vec3d MovCenter(uint tick)
|
||||
{
|
||||
return default(vec3d);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,9 @@ namespace StgSharp.Geometries
|
||||
public unsafe class Triangle : PlainGeometry
|
||||
{
|
||||
|
||||
public Triangle():base(PlainCoordinate.StandardPlainCoordination)
|
||||
internal static int[] Indices = [0, 1, 2];
|
||||
|
||||
public Triangle() : base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
vertexMat = new vec4d[3];
|
||||
}
|
||||
@@ -58,6 +60,17 @@ namespace StgSharp.Geometries
|
||||
this[2] = vertex03;
|
||||
}
|
||||
|
||||
public Triangle(PlainCoordinate coordination,
|
||||
Point vertex01,
|
||||
Point vertex02,
|
||||
Point vertex03
|
||||
) : base(coordination)
|
||||
{
|
||||
this[0] = vertex01;
|
||||
this[1] = vertex02;
|
||||
this[2] = vertex03;
|
||||
}
|
||||
|
||||
public Triangle(
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
@@ -69,17 +82,6 @@ namespace StgSharp.Geometries
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
}
|
||||
|
||||
public Triangle(PlainCoordinate coordination,
|
||||
Point vertex01,
|
||||
Point vertex02,
|
||||
Point vertex03
|
||||
) : base(coordination)
|
||||
{
|
||||
this[0] = vertex01;
|
||||
this[1] = vertex02;
|
||||
this[2] = vertex03;
|
||||
}
|
||||
|
||||
public Triangle(PlainCoordinate coordination,
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
@@ -90,7 +92,6 @@ namespace StgSharp.Geometries
|
||||
this[1] = new Point(v1x, v1y, 0);
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
}
|
||||
internal static int[] Indices = [ 0, 1, 2 ];
|
||||
|
||||
public override ReadOnlySpan<int> VertexIndices => Indices;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user