Prechádzať zdrojové kódy

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 rokov pred
rodič
commit
fc4243a08f
1 zmenil súbory, kde vykonal 1 pridanie a 0 odobranie
  1. 1 0
      code/ObjFileMtlImporter.cpp

+ 1 - 0
code/ObjFileMtlImporter.cpp

@@ -302,6 +302,7 @@ void ObjFileMtlImporter::createMaterial()
         // New Material created
         m_pModel->m_pCurrentMaterial = new ObjFile::Material();
         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_MaterialMap[ name ] = m_pModel->m_pCurrentMaterial;
     } else {