Browse Source

[ 3460982] Patch for Bug 3460978 - Obj loader not generating new objects for material groups.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1108 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
aramis_acg 13 years ago
parent
commit
2c0965795c
1 changed files with 9 additions and 0 deletions
  1. 9 0
      code/ObjFileParser.cpp

+ 9 - 0
code/ObjFileParser.cpp

@@ -377,6 +377,15 @@ void ObjFileParser::getFace(aiPrimitiveType type)
 //	Get values for a new material description
 void ObjFileParser::getMaterialDesc()
 {
+	// Each material request a new object.
+	// Sometimes the object is already created (see 'o' tag by example), but it is not initialized !
+	// So, we create a new object only if the current on is already initialized !
+	if (m_pModel->m_pCurrent != NULL &&
+		(	m_pModel->m_pCurrent->m_Meshes.size() > 1 ||
+			(m_pModel->m_pCurrent->m_Meshes.size() == 1 && m_pModel->m_Meshes[m_pModel->m_pCurrent->m_Meshes[0]]->m_Faces.size() != 0)	)
+		)
+		m_pModel->m_pCurrent = NULL;
+
 	// Get next data for material data
 	m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
 	if (m_DataIt == m_DataItEnd)