Skip to content

Commit

Permalink
closes assimp#1111: add warning when
Browse files Browse the repository at this point in the history
detecting invalid mat definition.
  • Loading branch information
kimkulling committed Dec 19, 2016
1 parent bd0449e commit b934331
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
5 changes: 4 additions & 1 deletion code/ObjFileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 19 additions & 1 deletion test/unit/utObjImportExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -180,7 +194,6 @@ class utObjImportExport : public AbstractImportExportBase {
return nullptr != scene;
}


protected:
Assimp::Importer *m_im;
aiScene *m_expectedScene;
Expand All @@ -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 );
}

0 comments on commit b934331

Please sign in to comment.