{"record":{"id":"b6ec65cfe79105b4","repo":"egametang/ET","slug":"rcbuildpolymesh-the-resulting-mesh-has-too-many-p","errorCode":null,"errorMessage":"rcBuildPolyMesh: The resulting mesh has too many polygons {mesh.npolys} (max {MAX_MESH_VERTS_POLY}). Data can be corrupted.","messagePattern":"rcBuildPolyMesh: The resulting mesh has too many polygons (.+?) \\(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":1206,"sourceCode":"                            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\n            using var timer = ctx.ScopedTimer(RcTimerLabel.RC_TIMER_MERGE_POLYMESH);\n\n            RcPolyMesh mesh = new RcPolyMesh();\n            mesh.nvp = meshes[0].nvp;\n            mesh.cs = meshes[0].cs;\n            mesh.ch = meshes[0].ch;","sourceCodeStart":1188,"sourceCodeEnd":1224,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.recast/Scripts/Core/Share/Recast/RecastMesh.cs#L1188-L1224","documentation":"The post-condition check at RecastMesh.cs:1206 verifies mesh.npolys does not exceed MAX_MESH_VERTS_POLY (65535) at the end of the primary rcBuildPolyMesh path. Exceeding it means the 16-bit polygon index fields overflowed, so the returned mesh may be corrupted.","triggerScenarios":"Fires immediately after the nverts check at :1200 in the same finalization block, when mesh.npolys > 65535 after all polygon storage is complete.","commonSituations":"Massively polygon-heavy navmesh from a huge or untiled level; low maxVertsPerPoly combined with dense contours; often co-occurs with error 302. Indicates the conservative maxTris guard (301) was not the binding constraint but the final 16-bit cap was.","solutions":["Tile the navmesh (rcConfig.tileSize) so each tile's polygon count stays far below 65535.","Raise maxVertsPerPoly to reduce polygon count per contour.","Raise cellSize / contourSimplificationError to coarsen geometry.","If building a merged mesh (MergePolyMeshes), confirm inputs aren't already near the limit."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { rcBuildPolyMesh(ctx, cset, nvp, out mesh); }\ncatch (Exception e) when (e.Message.Contains(\"too many polygons\") && e.Message.Contains(\"Data can be corrupted\")) {\n    Log.Error($\"Corrupt polymesh: {e.Message}\");\n    // discard mesh, re-bake with coarser config or smaller tiles\n}","preventionTips":["Cap per-tile polygon count in bake config.","Never consume a mesh that triggered a 'Data can be corrupted' throw.","Run automated bake-size assertions on level content."],"tags":["recast","navmesh","capacity-limit","data-corruption","polygon-count"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}