rename ungenericed graphic vec usage to genericed

This commit is contained in:
Youmu Liu
2026-09-04 18:51:27 +08:00
parent 41ca31fd9a
commit ee67dfbde1
20 changed files with 755 additions and 760 deletions
@@ -16,11 +16,11 @@ namespace Nitload.Geometries
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec3 DefaultMotion(
int tick
public static Vec3<float> DefaultMotion(
int tick
)
{
return default(Vec3);
return Vec3<float>.Zero;
}
}
@@ -18,7 +18,7 @@ namespace Nitload.Geometries
public interface IPlainEntity
{
public Vec2 CenterPosition { get; set; }
public Vec2<float> CenterPosition { get; set; }
public bool CollideWith(
IPlainEntity entity
@@ -45,7 +45,7 @@ namespace Nitload.Geometries
throw new NotImplementedException();
}
Vec2 IPlainEntity.CenterPosition
Vec2<float> IPlainEntity.CenterPosition
{
get => _shape.Coordination.LocalOrigin.Coord.XY;
set => throw new InvalidOperationException();
@@ -39,7 +39,7 @@ namespace Nitload.Geometries
public int BufferId { get; set; }
Vec3 IInstancing.CenterPositionGlobal { get; set; }
Vec3<float> IInstancing.CenterPositionGlobal { get; set; }
bool IPlainEntity.CollideWith(
IPlainEntity entity
@@ -48,7 +48,7 @@ namespace Nitload.Geometries
throw new NotImplementedException();
}
Vec2 IPlainEntity.CenterPosition
Vec2<float> IPlainEntity.CenterPosition
{
get => GlobalBuffer.CoordAndRotationList[BufferId].XY;
set => throw new NotImplementedException();
@@ -20,7 +20,7 @@ namespace Nitload.Geometries
public abstract class PlainGeometry : IGeometry
{
protected Vec4[] vertexMat;
protected Vec3<float>[] vertexMat;
internal CoordinationBase coordinate;
internal PlainGeometry(
@@ -34,8 +34,8 @@ namespace Nitload.Geometries
int index
]
{
get => new Point(vertexMat[index]);
set => vertexMat[index].vec = value.coordVec;
get => new(vertexMat[index]);
set => vertexMat[index] = value.Coord;
}
public int VertexCount => this.vertexMat.Length;
@@ -43,9 +43,9 @@ namespace Nitload.Geometries
public abstract ReadOnlySpan<int> VertexIndices { get; }
#pragma warning disable CA1819
public Vec4[] VertexStream => vertexMat;
public Vec3<float>[] VertexStream => vertexMat;
public CoordinationBase Coordination => this.coordinate;
#pragma warning restore CA1819
}
}
}
@@ -31,28 +31,28 @@ namespace Nitload.Geometries
private bool disposedValue;
private CoordinatePlain globalCoordinate;
private List<Vec4> coordList;
private List<Vec4<float>> coordList;
private List<IInstancing> instanceList;
private List<float> scalingList;
private Mutex mutex;
public PlainInstancingBuffer()
{
coordList = new List<Vec4>(capacity:100);
coordList = new List<Vec4<float>>(capacity:100);
instanceList = new List<IInstancing>(capacity:100);
scalingList = new List<float>(capacity:100);
coordArray = Array.Empty<Vec4>();
coordArray = Array.Empty<Vec4<float>>();
scaleArray = Array.Empty<float>();
mutex = new Mutex();
}
public List<IInstancing> InstanceList => instanceList;
public List<Vec4> CoordAndRotationList => coordList;
public List<Vec4<float>> CoordAndRotationList => coordList;
public List<float> ScalingList => scalingList;
public Span<Vec4> CoordAndRotationSpan => CollectionsMarshal.AsSpan(coordList);
public Span<Vec4<float>> CoordAndRotationSpan => CollectionsMarshal.AsSpan(coordList);
public Span<float> ScalingSpan => CollectionsMarshal.AsSpan(scalingList);
@@ -60,7 +60,7 @@ namespace Nitload.Geometries
{
mutex.WaitOne();
int ret = instanceList.Count;
coordList.Add(new Vec4());
coordList.Add(new Vec4<float>());
scalingList.Add(0);
mutex.ReleaseMutex();
return ret;
@@ -143,7 +143,7 @@ namespace Nitload.Geometries
#region field of mem opt
private Vec4[] coordArray;
private Vec4<float>[] coordArray;
private float[] scaleArray;
#endregion