diff --git a/tiny_obj_loader.h b/tiny_obj_loader.h index 187d2b8..d52e97c 100644 --- a/tiny_obj_loader.h +++ b/tiny_obj_loader.h @@ -2161,16 +2161,29 @@ bool LoadObj(attrib_t *attrib, std::vector *shapes, // Ignore unknown command. } - if (greatest_v_idx * 3 >= int(v.size()) - || greatest_vn_idx * 3 >= int(vn.size()) - || greatest_vt_idx * 2 >= int(vt.size())) + if (greatest_v_idx >= static_cast(v.size() / 3)) { if (err) { std::stringstream ss; - ss << "WARN: Indices do not match the data.\n" << std::endl; + ss << "WARN: Vertex indices out of bounds.\n" << std::endl; + (*err) += ss.str(); + } + } + if (greatest_vn_idx >= static_cast(vn.size() / 3)) + { + if (err) { + std::stringstream ss; + ss << "WARN: Vertex normal indices out of bounds.\n" << std::endl; + (*err) += ss.str(); + } + } + if (greatest_vt_idx >= static_cast(vt.size() / 2)) + { + if (err) { + std::stringstream ss; + ss << "WARN: Vertex texcoord indices out of bounds.\n" << std::endl; (*err) += ss.str(); } - return false; } bool ret = exportGroupsToShape(&shape, faceGroup, lineGroup, tags, material,