Fix material index off-by-one error in some OBJ files (seen in a C4D export)

This commit is contained in:
Josh Faust
2018-02-27 14:58:04 -08:00
parent a0465a1349
commit 190190c1d7
4 changed files with 53 additions and 2 deletions

View File

@@ -303,11 +303,12 @@ void ObjFileMtlImporter::createMaterial()
// New Material created
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
m_pModel->m_pCurrentMaterial->MaterialName.Set( name );
m_pModel->m_MaterialLib.push_back( name );
m_pModel->m_MaterialMap[ name ] = m_pModel->m_pCurrentMaterial;
if (m_pModel->m_pCurrentMesh) {
m_pModel->m_pCurrentMesh->m_uiMaterialIndex = static_cast<unsigned int>(m_pModel->m_MaterialLib.size() - 1);
}
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;