Skip to content

Commit

Permalink
update comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ikpil committed Jul 11, 2024
1 parent c1e7b84 commit afe93d0
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/DotRecast.Recast/RcMeshs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,13 @@ private static void RemoveVertex(RcContext ctx, RcPolyMesh mesh, int rem, int ma
int nv = CountPolyVerts(mesh.polys, p, nvp);
bool hasRem = false;
for (int j = 0; j < nv; ++j)
{
if (mesh.polys[p + j] == rem)
{
hasRem = true;
}
}

if (hasRem)
{
// Collect edges which does not touch the removed vertex.
Expand Down Expand Up @@ -956,7 +961,7 @@ private static void RemoveVertex(RcContext ctx, RcPolyMesh mesh, int rem, int ma
mesh.npolys++;
if (mesh.npolys > maxTris)
{
throw new Exception("removeVertex: Too many polygons " + mesh.npolys + " (max:" + maxTris + ".");
throw new Exception($"removeVertex: Too many polygons {mesh.npolys} max:({maxTris}).");
}
}
}
Expand Down Expand Up @@ -1033,11 +1038,23 @@ public static RcPolyMesh BuildPolyMesh(RcContext ctx, RcContourSet cset, int nvp
// Triangulate contour
for (int j = 0; j < cont.nverts; ++j)
indices[j] = j;

int ntris = Triangulate(cont.nverts, cont.verts, indices, tris);
if (ntris <= 0)
{
// Bad triangulation, should not happen.
ctx.Warn("buildPolyMesh: Bad triangulation Contour " + i + ".");
/*
printf("\tconst float bmin[3] = {%ff,%ff,%ff};\n", cset.bmin[0], cset.bmin[1], cset.bmin[2]);
printf("\tconst float cs = %ff;\n", cset.cs);
printf("\tconst float ch = %ff;\n", cset.ch);
printf("\tconst int verts[] = {\n");
for (int k = 0; k < cont.nverts; ++k)
{
const int* v = &cont.verts[k*4];
printf("\t\t%d,%d,%d,%d,\n", v[0], v[1], v[2], v[3]);
}
printf("\t};\n\tconst int nverts = sizeof(verts)/(sizeof(int)*4);\n");*/
ctx.Warn($"BuildPolyMesh: Bad triangulation Contour {i}.");
ntris = -ntris;
}

Expand Down Expand Up @@ -1198,14 +1215,12 @@ public static RcPolyMesh BuildPolyMesh(RcContext ctx, RcContourSet cset, int nvp

if (mesh.nverts > MAX_MESH_VERTS_POLY)
{
throw new Exception("rcBuildPolyMesh: The resulting mesh has too many vertices " + mesh.nverts
+ " (max " + MAX_MESH_VERTS_POLY + "). Data can be corrupted.");
throw new Exception($"BuildPolyMesh: The resulting mesh has too many vertices {mesh.nverts} (max {MAX_MESH_VERTS_POLY}). Data can be corrupted.");
}

if (mesh.npolys > MAX_MESH_VERTS_POLY)
{
throw new Exception("rcBuildPolyMesh: The resulting mesh has too many polygons " + mesh.npolys
+ " (max " + MAX_MESH_VERTS_POLY + "). Data can be corrupted.");
throw new Exception($"BuildPolyMesh: The resulting mesh has too many polygons {mesh.npolys} (max {MAX_MESH_VERTS_POLY}). Data can be corrupted.");
}

return mesh;
Expand Down

0 comments on commit afe93d0

Please sign in to comment.