- Bugfix : Bug 3511751 closed, handling no defined material name.
- Update : Add a model for the regression test. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1244 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
@@ -219,22 +219,29 @@ void ObjFileMtlImporter::getFloatValue( float &value )
|
||||
// Creates a material from loaded data.
|
||||
void ObjFileMtlImporter::createMaterial()
|
||||
{
|
||||
std::string strName( "" );
|
||||
m_DataIt = getName<DataArrayIt>( m_DataIt, m_DataItEnd, strName );
|
||||
if ( m_DataItEnd == m_DataIt )
|
||||
return;
|
||||
std::string line( "" );
|
||||
while ( !isNewLine( *m_DataIt ) ) {
|
||||
line += *m_DataIt;
|
||||
++m_DataIt;
|
||||
}
|
||||
|
||||
std::vector<std::string> token;
|
||||
const unsigned int numToken = tokenize<std::string>( line, token, " " );
|
||||
std::string name( "" );
|
||||
if ( numToken == 1 ) {
|
||||
name = AI_DEFAULT_MATERIAL_NAME;
|
||||
} else {
|
||||
name = token[ 1 ];
|
||||
}
|
||||
|
||||
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( strName );
|
||||
if ( m_pModel->m_MaterialMap.end() == it)
|
||||
{
|
||||
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( name );
|
||||
if ( m_pModel->m_MaterialMap.end() == it) {
|
||||
// New Material created
|
||||
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
|
||||
m_pModel->m_pCurrentMaterial->MaterialName.Set( strName );
|
||||
m_pModel->m_MaterialLib.push_back( strName );
|
||||
m_pModel->m_MaterialMap[ strName ] = m_pModel->m_pCurrentMaterial;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pModel->m_pCurrentMaterial->MaterialName.Set( name );
|
||||
m_pModel->m_MaterialLib.push_back( name );
|
||||
m_pModel->m_MaterialMap[ name ] = m_pModel->m_pCurrentMaterial;
|
||||
} else {
|
||||
// Use older material
|
||||
m_pModel->m_pCurrentMaterial = (*it).second;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user