From dea325cdcbed8644e50efca7bfec274286da3518 Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Sat, 13 Aug 2016 19:27:13 +0900 Subject: [PATCH] Fix face num calculation. --- experimental/tinyobj_loader_opt.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/experimental/tinyobj_loader_opt.h b/experimental/tinyobj_loader_opt.h index 91902fb..98fe73e 100644 --- a/experimental/tinyobj_loader_opt.h +++ b/experimental/tinyobj_loader_opt.h @@ -1397,7 +1397,7 @@ bool parseObj(attrib_t *attrib, std::vector *shapes, command_count[t].num_vt++; } else if (command.type == COMMAND_F) { command_count[t].num_f += command.f.size(); - command_count[t].num_indices++; + command_count[t].num_indices += command.f_num_verts.size(); } if (command.type == COMMAND_MTLLIB) { @@ -1556,11 +1556,13 @@ bool parseObj(attrib_t *attrib, std::vector *shapes, attrib->indices[f_count + k] = index_t(vertex_index, texcoord_index, normal_index); } - attrib->material_ids[face_count] = material_id; - attrib->face_num_verts[face_count] = commands[t][i].f.size(); + for (size_t k = 0; k < commands[t][i].f_num_verts.size(); k++) { + attrib->material_ids[face_count + k] = material_id; + attrib->face_num_verts[face_count + k] = commands[t][i].f_num_verts[k]; + } f_count += commands[t][i].f.size(); - face_count++; + face_count += commands[t][i].f_num_verts.size(); } } }));