daily update on 20240528 by nitload youmu

This commit is contained in:
Nitload
2024-05-28 17:45:54 +08:00
parent de399e22c2
commit 70890e3e33
88 changed files with 10678 additions and 5761 deletions
@@ -14,7 +14,6 @@ namespace StgSharp.Geometries
public vec2d CenterPosition { get; set; }
public bool CollideWith(IPlainEntity entity);
}
public class PlainEntity:IPlainEntity
@@ -0,0 +1,86 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="IInstancing.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Geometries
{
public class ParticleOnPlain : IInstancing, IPlainEntity
{
public ParticleOnPlain(PlainInstancingBuffer<ParticleOnPlain> buffer)
{
if (buffer == null)
{
throw new ArgumentNullException(paramName: nameof(buffer));
}
GlobalBuffer = buffer;
BufferId = buffer.CreateInstanceID();
((IInstancingBuffer)buffer).InstanceList.Add(this);
}
public int BufferId
{
get;
set;
}
public IInstancingBuffer GlobalBuffer
{
get;
set;
}
public GeometryMotion Motion
{
get;
set;
}
vec3d IInstancing.CenterPositionGlobal
{
get;
set;
}
vec2d IPlainEntity.CenterPosition { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
bool IPlainEntity.CollideWith(IPlainEntity entity)
{
throw new NotImplementedException();
}
}
}
@@ -32,68 +32,39 @@ using StgSharp.Graphics;
using StgSharp.Math;
using System;
using System.ComponentModel;
namespace StgSharp.Geometries
{
/// <summary>
/// 平面几何体。包含三角形,对称四边形,自由多边形等。最多可由16个点参数定义。
/// Plain geometry only contains straight sides.
/// </summary>
public abstract class PlainGeometry: IGeometry
public abstract class PlainGeometry : IGeometry
{
protected TimeSpanProvider time;
protected vec4d[] vertexMat;
internal ICoord coordinate;
public static int VertexCount { get; }
public PlainGeometry()
{
}
vec4d IGeometry.this[int index]
public vec4d this[int index]
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
get => vertexMat[index];
set => vertexMat[index] = value;
}
/// <summary>
/// Tick time this geometry eas crested
/// </summary>
public int BornTime => time;
public ICoord ReferenceCoordinate => this.coordinate;
internal abstract int[] Indices { get; }
public int VertexCount => this.vertexMat.Length;
int IGeometry.VertexCount => throw new NotImplementedException();
public abstract ReadOnlySpan<int> VertexIndices { get; }
vec4d[] IGeometry.VertexStream => throw new NotImplementedException();
#pragma warning disable CA1819
public vec4d[] VertexStream => vertexMat;
#pragma warning restore CA1819
/// <summary>
/// Get all sides of this <see cref="PlainGeometry"/>.
/// </summary>
/// <returns>A array contains all straight <see cref="Line"/>s of current geometry item.</returns>
public abstract Line[] GetAllSides();
/// <summary>
/// Get a flat <see cref="Plain"/> coincide with current geometry.
/// </summary>
/// <returns></returns>
public abstract Plain GetPlain();
internal abstract void UpdateCoordinate(int tick);
void IGeometry.GetVertexHandle(ICoord coordinate, int count)
{
throw new NotImplementedException();
}
void IGeometry.Transform(Matrix44 transFormMatrix)
{
throw new NotImplementedException();
}
//public abstract Rectangle GetRenderFrame();
}
}
@@ -44,12 +44,15 @@ using System.Threading.Tasks;
namespace StgSharp.Geometries
{
public class PlainInstancingBuffer<T> : IDisposable,IEnumerable<T> where T : IInstancing<T>
public class PlainInstancingBuffer<T> :
IDisposable,IEnumerable<T>, IInstancingBuffer
where T :
IInstancing
{
private CoordinatePlain globalCorrdinnate;
private List<vec4d> coordList;
private List<IInstancing<T>> instanceList;
private List<IInstancing> instanceList;
private List<float> scalingList;
private Mutex mutex;
private bool disposedValue;
@@ -64,29 +67,29 @@ namespace StgSharp.Geometries
public PlainInstancingBuffer()
{
coordList = new List<vec4d>(capacity: 100);
instanceList = new List<IInstancing<T>>(capacity:100);
instanceList = new List<IInstancing>(capacity:100);
scalingList = new List<float>(capacity: 100);
coordArray = new vec4d[0];
scaleArray = new float[0];
coordArray = Array.Empty<vec4d>();
scaleArray = Array.Empty<float>();
mutex = new Mutex();
}
internal List<IInstancing<T>> InstanceList
List<IInstancing> IInstancingBuffer.InstanceList
{
get => instanceList;
}
internal List<vec4d> CoordList
List<vec4d> IInstancingBuffer.CoordAndRotationList
{
get => coordList;
}
internal List<float> ScalingList
List<float> IInstancingBuffer.ScalingList
{
get => scalingList;
}
public Span<vec4d> CoordSpan
public Span<vec4d> CoordAndRotationSpan
{
get
{
@@ -96,7 +99,11 @@ namespace StgSharp.Geometries
GetField("_items", BindingFlags.NonPublic | BindingFlags.Instance);
if (fieldInfo == null)
{
#pragma warning disable CA1065
#pragma warning disable CA2201
throw new NullReferenceException();
#pragma warning restore CA2201
#pragma warning restore CA1065
}
coordArray = (vec4d[])fieldInfo.GetValue(coordList);
}
@@ -114,7 +121,11 @@ namespace StgSharp.Geometries
GetField("_items", BindingFlags.NonPublic | BindingFlags.Instance);
if (fieldInfo == null)
{
#pragma warning disable CA1065
#pragma warning disable CA2201
throw new NullReferenceException();
#pragma warning restore CA2201
#pragma warning restore CA1065
}
scaleArray = (float[])fieldInfo.GetValue(scalingList);
}
@@ -122,6 +133,8 @@ namespace StgSharp.Geometries
}
}
IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException();
public int CreateInstanceID()
{
mutex.WaitOne();
@@ -142,7 +155,7 @@ namespace StgSharp.Geometries
paramName: nameof(instance));
}
int index = instance.BufferId;
IInstancing<T> temp = instanceList[instanceList.Count - 1];
IInstancing temp = instanceList[instanceList.Count - 1];
instanceList[instance.BufferId] = temp;
temp.BufferId = instance.BufferId;