{"record":{"id":"cf3893226855da6d","repo":"egametang/ET","slug":"0-vertex-index","errorCode":null,"errorMessage":"0 vertex index","messagePattern":"0 vertex index","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.recast/Scripts/Core/Share/Recast/ObjImporter.cs","lineNumber":134,"sourceCode":"        private static int ReadFaceVertex(string face, ObjImporterContext context)\n        {\n            string[] v = face.Split(\"/\");\n            return GetIndex(int.Parse(v[0]), context.vertexPositions.Count);\n        }\n\n        private static int GetIndex(int posi, int size)\n        {\n            if (posi > 0)\n            {\n                posi--;\n            }\n            else if (posi < 0)\n            {\n                posi = size + posi;\n            }\n            else\n            {\n                throw new Exception(\"0 vertex index\");\n            }\n\n            return posi;\n        }\n    }\n}","sourceCodeStart":116,"sourceCodeEnd":140,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.recast/Scripts/Core/Share/Recast/ObjImporter.cs#L116-L140","documentation":"Thrown by ObjImporter.GetIndex when a face vertex reference resolves to index 0. OBJ indices are 1-based positive or negative (relative to end); 0 is explicitly invalid. This happens when a face references '0' or a component ('0/0/0') that decodes to zero.","triggerScenarios":"An 'f' line containing a literal 0 vertex reference (e.g., 'f 0 1 2'); a face vertex like '0/1/1' whose position index is 0.","commonSituations":"Exporters that zero-index instead of 1-indexing; hand-authored faces with a typo'd 0; corrupted face data.","solutions":["Locate the 'f' line referencing 0 and correct it to a valid 1-based (or valid negative) index.","Re-export from the source tool with correct OBJ 1-based indexing.","Pre-scan face tokens and reject any that equal 0 before importing."],"exampleFix":"// before\nf 0 1 2\n\n// after\nf 1 2 3","handlingStrategy":"validation","validationCode":"foreach (var line in lines)\n    if (line.StartsWith(\"f \"))\n        foreach (var tok in line.Substring(2).Split(' ', StringSplitOptions.RemoveEmptyEntries))\n        {\n            int slash = tok.IndexOf('/');\n            int pos = int.Parse(slash < 0 ? tok : tok.Substring(0, slash));\n            if (pos == 0) throw new InvalidDataException($\"Zero OBJ index in: {line}\");\n        }","typeGuard":"static bool HasNoZeroIndex(string faceToken)\n{ var p = faceToken.Split('/')[0]; return int.TryParse(p, out int i) && i != 0; }","tryCatchPattern":"try { ObjImporter.Load(chunk); }\ncatch (Exception e) when (e.Message.Contains(\"0 vertex index\"))\n{ /* correct the offending face reference */ }","preventionTips":["OBJ indices are 1-based; never use 0.","Re-export with a 1-based OBJ exporter.","Pre-scan face tokens for 0 references."],"tags":["recast","obj-import","parsing","validation","face-index"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}