Forráskód Böngészése

Obj: Change asserts to exceptions

These can be triggered by malformed input file so they can't be assertions.
Turo Lamminen 10 éve
szülő
commit
3e728e80eb
2 módosított fájl, 4 hozzáadás és 2 törlés
  1. 3 1
      code/ObjFileImporter.cpp
  2. 1 1
      code/ObjFileParser.cpp

+ 3 - 1
code/ObjFileImporter.cpp

@@ -424,7 +424,9 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
                 pMesh->mTextureCoords[ 0 ][ newIndex ] = aiVector3D( coord3d.x, coord3d.y, coord3d.z );
             }
 
-            ai_assert( pMesh->mNumVertices > newIndex );
+            if ( pMesh->mNumVertices <= newIndex ) {
+                throw DeadlyImportError("OBJ: bad vertex index");
+            }
 
             // Get destination face
             aiFace *pDestFace = &pMesh->mFaces[ outIndex ];

+ 1 - 1
code/ObjFileParser.cpp

@@ -259,7 +259,7 @@ void ObjFileParser::getVector( std::vector<aiVector3D> &point3d_array ) {
         copyNextWord( m_buffer, BUFFERSIZE );
         z = ( float ) fast_atof( m_buffer );
     } else {
-        ai_assert( !"Invalid number of components" );
+        throw DeadlyImportError( "OBJ: Invalid number of components" );
     }
     point3d_array.push_back( aiVector3D( x, y, z ) );
     m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );