trimming spaces around material names
parent
c9ef6132a8
commit
af40c99a6a
|
@ -284,6 +284,8 @@ void ObjFileMtlImporter::createMaterial()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name = trim_whitespaces(name);
|
||||||
|
|
||||||
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( name );
|
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( name );
|
||||||
if ( m_pModel->m_MaterialMap.end() == it) {
|
if ( m_pModel->m_MaterialMap.end() == it) {
|
||||||
// New Material created
|
// New Material created
|
||||||
|
|
|
@ -473,6 +473,7 @@ void ObjFileParser::getMaterialDesc()
|
||||||
|
|
||||||
// Get name
|
// Get name
|
||||||
std::string strName(pStart, &(*m_DataIt));
|
std::string strName(pStart, &(*m_DataIt));
|
||||||
|
strName = trim_whitespaces(strName);
|
||||||
if (strName.empty())
|
if (strName.empty())
|
||||||
skip = true;
|
skip = true;
|
||||||
|
|
||||||
|
|
|
@ -238,6 +238,14 @@ unsigned int tokenize( const string_type& str, std::vector<string_type>& tokens,
|
||||||
return static_cast<unsigned int>( tokens.size() );
|
return static_cast<unsigned int>( tokens.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class string_type>
|
||||||
|
string_type trim_whitespaces(string_type str)
|
||||||
|
{
|
||||||
|
while (!str.empty() && IsSpace(str[0])) str.erase(0);
|
||||||
|
while (!str.empty() && IsSpace(str[str.length() - 1])) str.erase(str.length() - 1);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
} // Namespace Assimp
|
} // Namespace Assimp
|
||||||
|
|
||||||
#endif // OBJ_TOOLS_H_INC
|
#endif // OBJ_TOOLS_H_INC
|
||||||
|
|
Loading…
Reference in New Issue