diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bfc474..9de7fcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 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[]) diff --git a/src/DotRecast.Detour.Extras/Unity/Astar/GraphMeshDataReader.cs b/src/DotRecast.Detour.Extras/Unity/Astar/GraphMeshDataReader.cs index 74c7f7f..db7124d 100644 --- a/src/DotRecast.Detour.Extras/Unity/Astar/GraphMeshDataReader.cs +++ b/src/DotRecast.Detour.Extras/Unity/Astar/GraphMeshDataReader.cs @@ -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; diff --git a/src/DotRecast.Detour/DtNavMeshBuilder.cs b/src/DotRecast.Detour/DtNavMeshBuilder.cs index bb9a276..632d89a 100644 --- a/src/DotRecast.Detour/DtNavMeshBuilder.cs +++ b/src/DotRecast.Detour/DtNavMeshBuilder.cs @@ -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) diff --git a/src/DotRecast.Detour/DtPolyDetail.cs b/src/DotRecast.Detour/DtPolyDetail.cs index 53fabec..5bc02f9 100644 --- a/src/DotRecast.Detour/DtPolyDetail.cs +++ b/src/DotRecast.Detour/DtPolyDetail.cs @@ -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; diff --git a/src/DotRecast.Detour/Io/DtMeshDataReader.cs b/src/DotRecast.Detour/Io/DtMeshDataReader.cs index a258c5d..7c837ed 100644 --- a/src/DotRecast.Detour/Io/DtMeshDataReader.cs +++ b/src/DotRecast.Detour/Io/DtMeshDataReader.cs @@ -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) {