daily update on 20240508 by nitload youmu, partical added
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class PlainInstancingBuffer<T> where T : IInstancing<T>
|
||||
{
|
||||
private List<Vector4> coordList;
|
||||
private List<float> scalingList;
|
||||
private List<IInstancing<T>> instanceList;
|
||||
|
||||
public PlainInstancingBuffer()
|
||||
{
|
||||
coordList = new List<Vector4>();
|
||||
instanceList = new List<IInstancing<T>>();
|
||||
scalingList = new List<float>();
|
||||
}
|
||||
|
||||
internal List<Vector4> CoordList
|
||||
{
|
||||
get => coordList;
|
||||
}
|
||||
|
||||
internal List<float> ScalingList
|
||||
{
|
||||
get => scalingList;
|
||||
}
|
||||
|
||||
public int CreateInstanceID()
|
||||
{
|
||||
int ret = instanceList.Count;
|
||||
coordList.Add(new Vector4());
|
||||
scalingList.Add(0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void Remove(T instance)
|
||||
{
|
||||
if (instance.GlobalBuffer != this)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
int index = instance.BufferId;
|
||||
IInstancing<T> 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];
|
||||
|
||||
instanceList.RemoveAt(instanceList.Count - 1);
|
||||
coordList.RemoveAt(coordList.Count - 1);
|
||||
scalingList.RemoveAt(scalingList.Count - 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user