{"record":{"id":"a2e263f8b919b707","repo":"egametang/ET","slug":"addedge-too-many-edges-edges-count-4-maxedg","errorCode":null,"errorMessage":"addEdge: Too many edges ({edges.Count / 4}/{maxEdges}).","messagePattern":"addEdge: Too many edges \\((.+?)/(.+?)\\)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"Packages/cn.etetet.recast/Scripts/Core/Share/Recast/RecastMeshDetail.cs","lineNumber":449,"sourceCode":"        private static int FindEdge(List<int> edges, int s, int t)\n        {\n            for (int i = 0; i < edges.Count / 4; i++)\n            {\n                int e = i * 4;\n                if ((edges[e + 0] == s && edges[e + 1] == t) || (edges[e + 0] == t && edges[e + 1] == s))\n                {\n                    return i;\n                }\n            }\n\n            return EV_UNDEF;\n        }\n\n        private static void AddEdge(RcTelemetry ctx, List<int> edges, int maxEdges, int s, int t, int l, int r)\n        {\n            if (edges.Count / 4 >= maxEdges)\n            {\n                throw new Exception(\"addEdge: Too many edges (\" + edges.Count / 4 + \"/\" + maxEdges + \").\");\n            }\n\n            // Add edge if not already in the triangulation.\n            int e = FindEdge(edges, s, t);\n            if (e == EV_UNDEF)\n            {\n                edges.Add(s);\n                edges.Add(t);\n                edges.Add(l);\n                edges.Add(r);\n            }\n        }\n\n        private static void UpdateLeftFace(List<int> edges, int e, int s, int t, int f)\n        {\n            if (edges[e + 0] == s && edges[e + 1] == t && edges[e + 2] == EV_UNDEF)\n            {\n                edges[e + 2] = f;","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.recast/Scripts/Core/Share/Recast/RecastMeshDetail.cs#L431-L467","documentation":"AddEdge in the detail mesh builder maintains a flat int-list of edges (4 ints per edge: s, t, left, right) and rejects adding a new edge once edges.Count/4 >= maxEdges. This bounds detail triangulation memory and is a hard cap on the half-edge structure used by Delaunay triangulation.","triggerScenarios":"DelaunayHull / detail mesh generation calls AddEdge when the edge count reaches the caller-supplied maxEdges. maxEdges is computed from the detail input size (typically maxVertexCount squared budget). Trips when a polygon requires more unique edges than the budget permits.","commonSituations":"Detail mesh build (rcBuildPolyMeshDetail) on a polygon with very many internal sample points (large sampleDist budget on a large poly); high detail sample density (small sampleDist) creating many edges; degenerate input geometry producing excessive triangulation edges.","solutions":["Reduce rcConfig.detailSampleDist (set larger, or 0 to disable internal sampling) to lower edge count.","Reduce rcConfig.detailSampleMaxError to require fewer detail subdivisions.","Coarsen the base polymesh (larger cellSize) so individual polygons are smaller and need fewer detail edges.","If you intentionally need high detail, confirm the maxEdges budget in DelaunayHull scales with your expected vertex count."],"exampleFix":"// before: dense detail sampling\ncfg.detailSampleDist = 0.5f;\ncfg.detailSampleMaxError = 0.5f;\n// after: relax detail sampling\ncfg.detailSampleDist = 6f;   // larger = fewer samples\ncfg.detailSampleMaxError = 1f;","handlingStrategy":"validation","validationCode":"// Sanity-check detail config before building detail\nif (cfg.detailSampleDist > 0 && cfg.detailSampleDist < cfg.cellSize)\n    Log.Warning(\"detailSampleDist smaller than cellSize may exceed edge budget on large polys\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep detailSampleDist >= cellSize to avoid excessive edge counts.","For large open areas, set detailSampleDist = 0 (no internal sampling).","Monitor detail build telemetry for tiles approaching the edge budget."],"tags":["recast","navmesh","detail-mesh","capacity-limit","edge-count"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}