Changed vertCount and triCount to byte in DtPolyDetail

This commit is contained in:
ikpil 2024-07-02 13:47:31 +09:00
parent ba6815769a
commit a282a80356
5 changed files with 12 additions and 11 deletions

View File

@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Changed to consolidate vector-related functions into one place.
- Changed stack handling from List to a fixed-size array with manual index management for optimization in `RcLayers.BuildHeightfieldLayers()`
- Changed to use Span<byte> and stackalloc for improved performance and memory management in `RcLayers.BuildHeightfieldLayers()`
- Changed vertCount and triCount to byte in `DtPolyDetail`
### Removed
- Removed RcMeshDetails.VdistSq2(float[], float[])

View File

@ -101,9 +101,9 @@ namespace DotRecast.Detour.Extras.Unity.Astar
ymax = Math.Max(ymax, verts[nodes[i].verts[1] * 3 + 1]);
ymax = Math.Max(ymax, verts[nodes[i].verts[2] * 3 + 1]);
int vertBase = 0;
int vertCount = 0;
byte vertCount = 0;
int triBase = i;
int triCount = 1;
byte triCount = 1;
detailNodes[i] = new DtPolyDetail(vertBase, triBase, vertCount, triCount);
detailTris[4 * i] = 0;
detailTris[4 * i + 1] = 1;

View File

@ -556,9 +556,9 @@ namespace DotRecast.Detour
int ndv = option.detailMeshes[i * 4 + 1];
int nv = navPolys[i].vertCount;
int vertBase = vbase;
int vertCount = (ndv - nv);
byte vertCount = (byte)(ndv - nv);
int triBase = option.detailMeshes[i * 4 + 2];
int triCount = option.detailMeshes[i * 4 + 3];
byte triCount = (byte)option.detailMeshes[i * 4 + 3];
navDMeshes[i] = new DtPolyDetail(vertBase, triBase, vertCount, triCount);
// Copy vertices except the first 'nv' verts which are equal to
// nav poly verts.
@ -580,9 +580,9 @@ namespace DotRecast.Detour
{
int nv = navPolys[i].vertCount;
int vertBase = 0;
int vertCount = 0;
byte vertCount = 0;
int triBase = tbase;
int triCount = (nv - 2);
byte triCount = (byte)(nv - 2);
navDMeshes[i] = new DtPolyDetail(vertBase, triBase, vertCount, triCount);
// Triangulate polygon (local indices).
for (int j = 2; j < nv; ++j)

View File

@ -25,10 +25,10 @@ namespace DotRecast.Detour
{
public readonly int vertBase; //< The offset of the vertices in the dtMeshTile::detailVerts array.
public readonly int triBase; //< The offset of the triangles in the dtMeshTile::detailTris array.
public readonly int vertCount; //< The number of vertices in the sub-mesh.
public readonly int triCount; //< The number of triangles in the sub-mesh.
public readonly byte vertCount; //< The number of vertices in the sub-mesh.
public readonly byte triCount; //< The number of triangles in the sub-mesh.
public DtPolyDetail(int vertBase, int triBase, int vertCount, int triCount)
public DtPolyDetail(int vertBase, int triBase, byte vertCount, byte triCount)
{
this.vertBase = vertBase;
this.triBase = triBase;

View File

@ -173,8 +173,8 @@ namespace DotRecast.Detour.Io
{
int vertBase = buf.GetInt();
int triBase = buf.GetInt();
int vertCount = buf.Get() & 0xFF;
int triCount = buf.Get() & 0xFF;
byte vertCount = (byte)(buf.Get() & 0xFF);
byte triCount = (byte)(buf.Get() & 0xFF);
polys[i] = new DtPolyDetail(vertBase, triBase, vertCount, triCount);
if (cCompatibility)
{