浏览代码

OBJParser: set material index when changing current material

When a new material is parsed from the material library, the name of the current material is set but the old material index remains. This leaves an incorrect material index in the current mesh causing textures to not be associated with the right mesh. This patch updates the material index when changing the material name.

submitted by: Nola Donato [email protected]
[email protected] 8 年之前
父节点
当前提交
fc4243a08f
共有 1 个文件被更改,包括 1 次插入0 次删除
  1. 1 0
      code/ObjFileMtlImporter.cpp

+ 1 - 0
code/ObjFileMtlImporter.cpp

@@ -302,6 +302,7 @@ void ObjFileMtlImporter::createMaterial()
         // New Material created
         // New Material created
         m_pModel->m_pCurrentMaterial = new ObjFile::Material();
         m_pModel->m_pCurrentMaterial = new ObjFile::Material();
         m_pModel->m_pCurrentMaterial->MaterialName.Set( name );
         m_pModel->m_pCurrentMaterial->MaterialName.Set( name );
+        m_pModel->m_pCurrentMesh->m_uiMaterialIndex = m_pModel->m_MaterialLib.size();
         m_pModel->m_MaterialLib.push_back( name );
         m_pModel->m_MaterialLib.push_back( name );
         m_pModel->m_MaterialMap[ name ] = m_pModel->m_pCurrentMaterial;
         m_pModel->m_MaterialMap[ name ] = m_pModel->m_pCurrentMaterial;
     } else {
     } else {