Merge pull request #1025 from smalcom/issue_768

Issue 768
pull/1027/head
Kim Kulling 2016-10-09 18:09:19 +02:00 committed by GitHub
commit 47dd1eb227
1 changed files with 13 additions and 2 deletions

View File

@ -182,10 +182,15 @@ void ObjFileParser::parseFile()
case 'm': // Parse a material library or merging group ('mg') case 'm': // Parse a material library or merging group ('mg')
{ {
if (*(m_DataIt + 1) == 'g') std::string name;
getName(m_DataIt, m_DataItEnd, name);
if (name == "mg")
getGroupNumberAndResolution(); getGroupNumberAndResolution();
else else if(name == "mtllib")
getMaterialLib(); getMaterialLib();
else
goto pf_skip_line;
} }
break; break;
@ -209,6 +214,8 @@ void ObjFileParser::parseFile()
default: default:
{ {
pf_skip_line:
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine ); m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
} }
break; break;
@ -625,6 +632,10 @@ void ObjFileParser::getMaterialLib()
// Check for existence // Check for existence
const std::string strMatName(pStart, &(*m_DataIt)); const std::string strMatName(pStart, &(*m_DataIt));
std::string absName; std::string absName;
// Check if directive is valid.
if(!strMatName.length()) throw DeadlyImportError("File name of the material is absent.");
if ( m_pIO->StackSize() > 0 ) { if ( m_pIO->StackSize() > 0 ) {
std::string path = m_pIO->CurrentDirectory(); std::string path = m_pIO->CurrentDirectory();
if ( '/' != *path.rbegin() ) { if ( '/' != *path.rbegin() ) {