Merge pull request #1115 from assimp/issue1111

closes https://github.com/assimp/assimp/issues/1111: add warning when
pull/1119/head
Kim Kulling 2016-12-19 21:37:46 +01:00 committed by GitHub
commit 05d9bfc762
2 changed files with 23 additions and 2 deletions

View File

@ -568,7 +568,10 @@ void ObjFileParser::getMaterialLib() {
std::string absName;
// Check if directive is valid.
if(!strMatName.length()) throw DeadlyImportError("File name of the material is absent.");
if ( 0 == strMatName.length() ) {
DefaultLogger::get()->warn( "OBJ: no name for material library specified." );
return;
}
if ( m_pIO->StackSize() > 0 ) {
std::string path = m_pIO->CurrentDirectory();

View File

@ -101,6 +101,20 @@ static const std::string ObjModel =
"\n"
"# End of file\n";
static const std::string ObjModel_Issue1111 =
"o 1\n"
"\n"
"# Vertex list\n"
"\n"
"v -0.5 -0.5 0.5\n"
"v -0.5 -0.5 -0.5\n"
"v -0.5 0.5 -0.5\n"
"\n"
"usemtl\n"
"f 1 2 3\n"
"\n"
"# End of file\n";
class utObjImportExport : public AbstractImportExportBase {
protected:
virtual void SetUp() {
@ -180,7 +194,6 @@ protected:
return nullptr != scene;
}
protected:
Assimp::Importer *m_im;
aiScene *m_expectedScene;
@ -201,3 +214,8 @@ TEST_F( utObjImportExport, obj_import_test ) {
m_im->FreeScene();
}
TEST_F( utObjImportExport, issue1111_no_mat_name_Test ) {
const aiScene *scene = m_im->ReadFileFromMemory( ( void* ) ObjModel_Issue1111.c_str(), ObjModel_Issue1111.size(), 0 );
EXPECT_NE( nullptr, scene );
}