Browse Source

Merge pull request #189 from AIM360/FixForDegeneratedObjFiles

SortByPType Posprocessing crashed for crappy models with degenerated geometry
Kim Kulling 11 years ago
parent
commit
f7e1502dd8
1 changed files with 4 additions and 1 deletions
  1. 4 1
      code/SortByPTypeProcess.cpp

+ 4 - 1
code/SortByPTypeProcess.cpp

@@ -151,7 +151,7 @@ void SortByPTypeProcess::Execute( aiScene* pScene)
 	std::vector<unsigned int>::iterator meshIdx = replaceMeshIndex.begin();
 	for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
 	{
-		aiMesh* mesh = pScene->mMeshes[i];
+		aiMesh* const mesh = pScene->mMeshes[i];
 		ai_assert(0 != mesh->mPrimitiveTypes);
 
 		// if there's just one primitive type in the mesh there's nothing to do for us
@@ -367,6 +367,9 @@ void SortByPTypeProcess::Execute( aiScene* pScene)
 
 		// delete the input mesh
 		delete mesh;
+
+        // avoid invalid pointer
+        pScene->mMeshes[i] = NULL;
 	}
 
 	if (outMeshes.empty())