From 2c0965795cd1e8c6ec86a9fd07723950996c3e08 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Wed, 11 Jan 2012 13:38:56 +0000 Subject: [PATCH] [ 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 --- code/ObjFileParser.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 8a61fb8f9..94923ff81 100644 --- a/code/ObjFileParser.cpp +++ b/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(m_DataIt, m_DataItEnd); if (m_DataIt == m_DataItEnd)