Improved OBJ Reader to not segfault on problems regarding texture coordinates

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@96 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Jan Möbius
2009-04-17 14:23:37 +00:00
parent 93f7d0322f
commit d7716799d4

View File

@@ -430,9 +430,13 @@ read(std::fstream& _in, BaseImporter& _bi, Options& _opt)
value = _bi.n_vertices() + value + 1; value = _bi.n_vertices() + value + 1;
} }
assert(!vhandles.empty()); assert(!vhandles.empty());
assert((unsigned int)(value-1) < texcoords.size()); if ( ! texcoords.empty() && (unsigned int)(value-1) < texcoords.size() ) {
_bi.set_texcoord(vhandles.back(), texcoords[value-1]); _bi.set_texcoord(vhandles.back(), texcoords[value-1]);
face_texcoords.push_back( texcoords[value-1] ); face_texcoords.push_back( texcoords[value-1] );
} else {
omerr() << "Error setting Texture coordinates" << std::endl;
}
break; break;
case 2: // normal case 2: // normal