daily update on 20240828 by nitload youmu, autotexture added

This commit is contained in:
Nitload
2024-08-28 10:58:31 +08:00
parent d082071f2d
commit 1ee4e4a42f
586 changed files with 60910 additions and 123106 deletions
@@ -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
}
}