{"record":{"id":"3c023f333f98cd9e","repo":"egametang/ET","slug":"rcbuildpolymesh-the-resulting-mesh-has-too-many-v","errorCode":null,"errorMessage":"rcBuildPolyMesh: The resulting mesh has too many vertices {mesh.nverts} (max {MAX_MESH_VERTS_POLY}). Data can be corrupted.","messagePattern":"rcBuildPolyMesh: The resulting mesh has too many vertices (.+?) \\(max (.+?)\\)\\. Data can be corrupted\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"Packages/cn.etetet.recast/Scripts/Core/Share/Recast/RecastMesh.cs","lineNumber":1200,"sourceCode":"\n                        if (mesh.verts[va + 0] == 0 && mesh.verts[vb + 0] == 0)\n                            mesh.polys[p + nvp + j] = 0x8000 | 0;\n                        else if (mesh.verts[va + 2] == h && mesh.verts[vb + 2] == h)\n                            mesh.polys[p + nvp + j] = 0x8000 | 1;\n                        else if (mesh.verts[va + 0] == w && mesh.verts[vb + 0] == w)\n                            mesh.polys[p + nvp + j] = 0x8000 | 2;\n                        else if (mesh.verts[va + 2] == 0 && mesh.verts[vb + 2] == 0)\n                            mesh.polys[p + nvp + j] = 0x8000 | 3;\n                    }\n                }\n            }\n\n            // Just allocate the mesh flags array. The user is resposible to fill it.\n            mesh.flags = new int[mesh.npolys];\n\n            if (mesh.nverts > MAX_MESH_VERTS_POLY)\n            {\n                throw new Exception(\"rcBuildPolyMesh: The resulting mesh has too many vertices \" + mesh.nverts\n                                                                                                 + \" (max \" + MAX_MESH_VERTS_POLY + \"). Data can be corrupted.\");\n            }\n\n            if (mesh.npolys > MAX_MESH_VERTS_POLY)\n            {\n                throw new Exception(\"rcBuildPolyMesh: The resulting mesh has too many polygons \" + mesh.npolys\n                                                                                                 + \" (max \" + MAX_MESH_VERTS_POLY + \"). Data can be corrupted.\");\n            }\n\n            return mesh;\n        }\n\n        /// @see rcAllocPolyMesh, rcPolyMesh\n        public static RcPolyMesh MergePolyMeshes(RcTelemetry ctx, RcPolyMesh[] meshes, int nmeshes)\n        {\n            if (nmeshes == 0 || meshes == null)\n                return null;\n","sourceCodeStart":1182,"sourceCodeEnd":1218,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.recast/Scripts/Core/Share/Recast/RecastMesh.cs#L1182-L1218","documentation":"After detail work and just before returning, rcBuildPolyMesh verifies the final vertex count does not exceed MAX_MESH_VERTS_POLY (0xffff = 65535). This is a post-condition integrity check: the mesh data may already be corrupted because 16-bit index fields overflowed, hence the 'Data can be corrupted' message.","triggerScenarios":"Reached at RecastMesh.cs:1200 in the primary build path. Fires when, after edge-vertex removal and mesh finalization, nverts grew beyond 65535 — indicating internal vertex addition during simplification/removal exceeded the index field width.","commonSituations":"Same class as error 300/301 but manifesting later: oversized tiles, too-small cellSize, or geometry where vertex removal/reinsertion inflates the count. Typically indicates the upstream capacity guard (300) was bypassed by a code path that added vertices after the initial allocation.","solutions":["Apply the same fixes as error 300: tile the world and/or increase cellSize to keep nverts well under 65535.","Treat as a defect indicator if it persists — the post-condition should be unreachable when the entry guard works, so verify contour partitioning and tile size are correct.","Capture telemetry (log cset total nverts at entry) to confirm which tile overflows and adjust its bounds."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Treat as a build-time failure: don't ship a possibly-corrupt mesh\ntry { rcBuildPolyMesh(ctx, cset, nvp, out mesh); }\ncatch (Exception e) when (e.Message.Contains(\"Data can be corrupted\")) {\n    Log.Error($\"Navmesh build produced corrupt data: {e.Message}\");\n    // do NOT use mesh; re-bake with coarser settings\n}","preventionTips":["Treat 'Data can be corrupted' throws as defects, not recoverable states — never use the partial mesh.","Keep total nverts well under 65535 via tiling.","Add CI bake tests that fail when vertex counts exceed 80% of the limit."],"tags":["recast","navmesh","capacity-limit","data-corruption","vertex-count"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}