OpenGEX: improve logging to be able to detect error-prone situations.
authorKim Kulling <kim.kulling@googlemail.com>
Mon, 2 Oct 2017 07:41:01 +0000 (09:41 +0200)
committerKim Kulling <kim.kulling@googlemail.com>
Mon, 2 Oct 2017 07:41:01 +0000 (09:41 +0200)
code/OpenGEXImporter.cpp

index 7c4d0f9..d9c58e9 100644 (file)
@@ -1182,8 +1182,16 @@ void OpenGEXImporter::resolveReferences() {
                     const std::string name( currentRefInfo->m_Names[ i ] );
                     ReferenceMap::const_iterator it( m_material2refMap.find( name ) );
                     if ( m_material2refMap.end() != it ) {
-                        unsigned int matIdx = static_cast< unsigned int >( m_material2refMap[ name ] );
-                        m_currentMesh->mMaterialIndex = matIdx;
+                        if ( nullptr != m_currentMesh ) {
+                            unsigned int matIdx = static_cast< unsigned int >( m_material2refMap[ name ] );
+                            if ( m_currentMesh->mMaterialIndex != 0 ) {
+                                DefaultLogger::get()->warn( "Override of material reference in current mesh by material reference." );
+                            }
+                            m_currentMesh->mMaterialIndex = matIdx;
+                        }  else {
+                            DefaultLogger::get()->warn( "Cannot resolve material reference, because no current mesh is there." );
+
+                        }
                     }
                 }
             } else {