diff --git a/code/ObjFileImporter.cpp b/code/ObjFileImporter.cpp index d40550b36..a3610c7b9 100644 --- a/code/ObjFileImporter.cpp +++ b/code/ObjFileImporter.cpp @@ -335,14 +335,20 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel, for ( size_t vertexIndex = 0; vertexIndex < pSourceFace->m_pVertices->size(); vertexIndex++ ) { const unsigned int vertex = pSourceFace->m_pVertices->at( vertexIndex ); - ai_assert( vertex < pModel->m_Vertices.size() ); + if (vertex >= pModel->m_Vertices.size()) { + throw DeadlyImportError("OBJ: vertex index out of range"); + } + pMesh->mVertices[ newIndex ] = pModel->m_Vertices[ vertex ]; // Copy all normals if ( !pSourceFace->m_pNormals->empty() ) { const unsigned int normal = pSourceFace->m_pNormals->at( vertexIndex ); - ai_assert( normal < pModel->m_Normals.size() ); + if (normal >= pModel->m_Normals.size()) { + throw DeadlyImportError("OBJ: vertex normal index out of range"); + } + pMesh->mNormals[ newIndex ] = pModel->m_Normals[ normal ]; } @@ -401,8 +407,10 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc const unsigned int numMaterials = (unsigned int) pModel->m_MaterialLib.size(); pScene->mNumMaterials = 0; - if ( pModel->m_MaterialLib.empty() ) + if ( pModel->m_MaterialLib.empty() ) { + DefaultLogger::get()->debug("OBJ: no materials specified"); return; + } pScene->mMaterials = new aiMaterial*[ numMaterials ]; for ( unsigned int matIndex = 0; matIndex < numMaterials; matIndex++ ) @@ -435,7 +443,7 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc break; default: sm = aiShadingMode_Gouraud; - DefaultLogger::get()->error("OBJ/MTL: Unexpected illumination model (0-2 recognized)"); + DefaultLogger::get()->error("OBJ: unexpected illumination model (0-2 recognized)"); } mat->AddProperty( &sm, 1, AI_MATKEY_SHADING_MODEL); diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 17dcf339b..8dfa9b9e7 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -388,6 +388,7 @@ void ObjFileParser::getMaterialDesc() { // Not found, use default material m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial; + DefaultLogger::get()->error("OBJ: failed to locate material " + strName + ", skipping"); } else {