Skip to content

Commit dea325c

Browse files
committed
Fix face num calculation.
1 parent 2b50b31 commit dea325c

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

experimental/tinyobj_loader_opt.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ bool parseObj(attrib_t *attrib, std::vector<shape_t> *shapes,
13971397
command_count[t].num_vt++;
13981398
} else if (command.type == COMMAND_F) {
13991399
command_count[t].num_f += command.f.size();
1400-
command_count[t].num_indices++;
1400+
command_count[t].num_indices += command.f_num_verts.size();
14011401
}
14021402

14031403
if (command.type == COMMAND_MTLLIB) {
@@ -1556,11 +1556,13 @@ bool parseObj(attrib_t *attrib, std::vector<shape_t> *shapes,
15561556
attrib->indices[f_count + k] =
15571557
index_t(vertex_index, texcoord_index, normal_index);
15581558
}
1559-
attrib->material_ids[face_count] = material_id;
1560-
attrib->face_num_verts[face_count] = commands[t][i].f.size();
1559+
for (size_t k = 0; k < commands[t][i].f_num_verts.size(); k++) {
1560+
attrib->material_ids[face_count + k] = material_id;
1561+
attrib->face_num_verts[face_count + k] = commands[t][i].f_num_verts[k];
1562+
}
15611563

15621564
f_count += commands[t][i].f.size();
1563-
face_count++;
1565+
face_count += commands[t][i].f_num_verts.size();
15641566
}
15651567
}
15661568
}));

0 commit comments

Comments
 (0)