Merge pull request #189 from AIM360/FixForDegeneratedObjFiles

SortByPType Posprocessing crashed for crappy models with degenerated geometry
pull/195/merge
Kim Kulling 2013-11-25 04:59:05 -08:00
commit f7e1502dd8
1 changed files with 4 additions and 1 deletions

View File

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