[VCS-1030] fallback for non-found .mtl file: try file name of original obj with just the file extension replaced by "mtl"
This commit is contained in:
committed by
ViewAR Win32
parent
76e4e82ecb
commit
abb3e6b854
@@ -61,13 +61,14 @@ const std::string ObjFileParser::DEFAULT_MATERIAL = AI_DEFAULT_MATERIAL_NAME;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Constructor with loaded data and directories.
|
||||
ObjFileParser::ObjFileParser(std::vector<char> &data,const std::string &modelName, IOSystem *io, ProgressHandler* progress ) :
|
||||
ObjFileParser::ObjFileParser(std::vector<char> &data, const std::string &modelName, IOSystem *io, ProgressHandler* progress, const std::string &originalObjFileName) :
|
||||
m_DataIt(data.begin()),
|
||||
m_DataItEnd(data.end()),
|
||||
m_pModel(NULL),
|
||||
m_uiLine(0),
|
||||
m_pIO( io ),
|
||||
m_progress(progress)
|
||||
m_progress(progress),
|
||||
m_originalObjFileName(originalObjFileName)
|
||||
{
|
||||
std::fill_n(m_buffer,Buffersize,0);
|
||||
|
||||
@@ -573,9 +574,14 @@ void ObjFileParser::getMaterialLib()
|
||||
IOStream *pFile = m_pIO->Open( absName );
|
||||
|
||||
if (!pFile ) {
|
||||
DefaultLogger::get()->error( "OBJ: Unable to locate material file " + strMatName );
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
return;
|
||||
DefaultLogger::get()->error("OBJ: Unable to locate material file " + strMatName);
|
||||
std::string strMatFallbackName = m_originalObjFileName.substr(0, m_originalObjFileName.length() - 3) + "mtl";
|
||||
pFile = m_pIO->Open(strMatFallbackName);
|
||||
if (!pFile) {
|
||||
DefaultLogger::get()->error("OBJ: Unable to locate material fallback file " + strMatName);
|
||||
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Import material library data from file.
|
||||
|
||||
Reference in New Issue
Block a user