MCPcopy Create free account
hub / github.com/axmolengine/axmol / parseTriple

Function parseTriple

core/3d/ObjLoader.cpp:290–324  ·  view source on GitHub ↗

Parse triples: i, i/j/k, i//k, i/j

Source from the content-addressed store, hash-verified

288
289// Parse triples: i, i/j/k, i//k, i/j
290static vertex_index parseTriple(const char*& token, int vsize, int vnsize, int vtsize)
291{
292 vertex_index vi(-1);
293
294 vi.v_idx = fixIndex(atoi(token), vsize);
295 token += strcspn(token, "/ \t\r");
296 if (token[0] != '/')
297 {
298 return vi;
299 }
300 token++;
301
302 // i//k
303 if (token[0] == '/')
304 {
305 token++;
306 vi.vn_idx = fixIndex(atoi(token), vnsize);
307 token += strcspn(token, "/ \t\r");
308 return vi;
309 }
310
311 // i/j/k or i/j
312 vi.vt_idx = fixIndex(atoi(token), vtsize);
313 token += strcspn(token, "/ \t\r");
314 if (token[0] != '/')
315 {
316 return vi;
317 }
318
319 // i/j/k
320 token++; // skip '/'
321 vi.vn_idx = fixIndex(atoi(token), vnsize);
322 token += strcspn(token, "/ \t\r");
323 return vi;
324}
325
326static std::string_view nextWord(const char* token) {
327 const char* endptr = strpbrk(token, " \t");

Callers 1

LoadObjFunction · 0.85

Calls 1

fixIndexFunction · 0.85

Tested by

no test coverage detected