{"record":{"id":"87f4a90830782f72","repo":"egametang/ET","slug":"buffer-too-small","errorCode":null,"errorMessage":"Buffer too small","messagePattern":"Buffer too small","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.recast/Scripts/Core/Share/Detour.TileCache/DtTileCacheBuilder.cs","lineNumber":137,"sourceCode":"                }\n\n                // Create unique ID.\n                for (int i = 0; i < sweepId; ++i)\n                {\n                    // If the neighbour is set and there is only one continuous\n                    // connection to it,\n                    // the sweep will be merged with the previous one, else new\n                    // region is created.\n                    if (sweeps[i].nei != 0xff && prevCount[sweeps[i].nei] == sweeps[i].ns)\n                    {\n                        sweeps[i].id = sweeps[i].nei;\n                    }\n                    else\n                    {\n                        if (regId == 255)\n                        {\n                            // Region ID's overflow.\n                            throw new Exception(\"Buffer too small\");\n                        }\n\n                        sweeps[i].id = regId++;\n                    }\n                }\n\n                // Remap local sweep ids to region ids.\n                for (int x = 0; x < w; ++x)\n                {\n                    int idx = x + y * w;\n                    if (layer.regs[idx] != 0xff)\n                        layer.regs[idx] = (short)sweeps[layer.regs[idx]].id;\n                }\n            }\n\n            // Allocate and init layer regions.\n            int nregs = regId;\n            DtLayerMonotoneRegion[] regs = new DtLayerMonotoneRegion[nregs];","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.recast/Scripts/Core/Share/Detour.TileCache/DtTileCacheBuilder.cs#L119-L155","documentation":"During monotone region partitioning of a tile-cache layer (DtTileCacheBuilder.BuildTileCacheRegions/MarkRectArea region sweep), each distinct region needs a unique id. Region ids are stored in a byte, so the partition supports at most 254 active regions; when regId reaches 255 the builder aborts with 'Buffer too small'. It means the layer's walkable spans fragment into more monotone regions than the encoding can address.","triggerScenarios":"Building a tile-cache layer whose walkable area is highly fragmented: many disjoint walkable islands, thin corridors, or heavy obstacle carving within one tile. Triggered by DtTileCache.BuildNavMeshTile -> builder region step on such a layer.","commonSituations":"Tile size too large relative to geometry complexity; many small obstacles carved into a single tile; noisy heightfield with many isolated ledges; cell size too coarse creating fragmentation.","solutions":["Reduce the tile dimensions (smaller cs/ch tileSize) so each layer holds fewer fragmented regions.","Simplify collision geometry feeding the rasterizer to cut down on tiny walkable islands.","Move/lower obstacle density so a single tile isn't carved into >254 regions."],"exampleFix":"// before: large tile, dense obstacles\nvar cp = new DtTileCacheParams { width = 256, height = 256, ch = 0.2f, cs = 0.3f, ... };\n\n// after: smaller tile per layer reduces region fragmentation\nvar cp = new DtTileCacheParams { width = 128, height = 128, ch = 0.2f, cs = 0.3f, ... };","handlingStrategy":"validation","validationCode":"// Heuristic guard before building a tile-cache layer:\n// keep per-tile walkable fragmentation well under 254 regions.\n// Validate tile size vs geometry density in your bake config.\nif (tileWidth * tileHeight > MaxCellsPerTile)\n    throw new InvalidOperationException(\n        \"Tile too large/dense; reduce tileSize or cs to keep monotone regions < 255.\");","typeGuard":null,"tryCatchPattern":"try { cache.BuildNavMeshTile(ref); }\ncatch (Exception e) when (e.Message == \"Buffer too small\")\n{ /* re-bake this tile smaller or simplify its geometry */ }","preventionTips":["Keep tile footprint modest so each layer fragments into < 255 monotone regions.","Simplify collision geometry to reduce tiny walkable islands.","Avoid packing many obstacles into a single tile."],"tags":["capacity","detour-tilecache","builder","geometry"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}