give respective warnings but allow partially correct data to be returned

This commit is contained in:
Vincent de Marignac
2018-08-16 23:34:47 +03:00
parent 7d20e9b901
commit 68350e2fc7

View File

@@ -2161,16 +2161,29 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *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<int>(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<int>(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<int>(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,