From 9eeaf19eab311c431515b53c53563e8792886898 Mon Sep 17 00:00:00 2001 From: Arkeon Date: Thu, 20 Sep 2018 10:31:32 +0200 Subject: [PATCH] Allow findDegenerate and SplitLargeMesh to pass point clouds models. Otherwise the model is removed or crash --- code/FindDegenerates.cpp | 6 ++++-- code/SplitLargeMeshes.cpp | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/code/FindDegenerates.cpp b/code/FindDegenerates.cpp index a3e9e0406..c0c0de08b 100644 --- a/code/FindDegenerates.cpp +++ b/code/FindDegenerates.cpp @@ -91,8 +91,10 @@ void FindDegeneratesProcess::SetupProperties(const Importer* pImp) { // Executes the post processing step on the given imported data. void FindDegeneratesProcess::Execute( aiScene* pScene) { ASSIMP_LOG_DEBUG("FindDegeneratesProcess begin"); - for (unsigned int i = 0; i < pScene->mNumMeshes;++i){ - if (ExecuteOnMesh(pScene->mMeshes[i])) { + for (unsigned int i = 0; i < pScene->mNumMeshes;++i) + { + //Do not process point cloud, ExecuteOnMesh works only with faces data + if ((pScene->mMeshes[i]->mPrimitiveTypes != aiPrimitiveType::aiPrimitiveType_POINT) && ExecuteOnMesh(pScene->mMeshes[i])) { removeMesh(pScene, i); --i; //the current i is removed, do not skip the next one } diff --git a/code/SplitLargeMeshes.cpp b/code/SplitLargeMeshes.cpp index 28b655fa4..60828f057 100644 --- a/code/SplitLargeMeshes.cpp +++ b/code/SplitLargeMeshes.cpp @@ -377,14 +377,22 @@ void SplitLargeMeshesProcess_Vertex::Execute( aiScene* pScene) { std::vector > avList; - if (0xffffffff == this->LIMIT)return; + if (0xffffffff == this->LIMIT) + return; ASSIMP_LOG_DEBUG("SplitLargeMeshesProcess_Vertex begin"); - for( unsigned int a = 0; a < pScene->mNumMeshes; a++) - this->SplitMesh(a, pScene->mMeshes[a],avList); - if (avList.size() != pScene->mNumMeshes) - { + //Check for point cloud first, + //Do not process point cloud, splitMesh works only with faces data + for (unsigned int a = 0; a < pScene->mNumMeshes; a++) { + if ((pScene->mMeshes[a]->mPrimitiveTypes == aiPrimitiveType::aiPrimitiveType_POINT)) + return; + } + + for( unsigned int a = 0; a < pScene->mNumMeshes; a++) + this->SplitMesh(a, pScene->mMeshes[a], avList); + + if (avList.size() != pScene->mNumMeshes) { // it seems something has been split. rebuild the mesh list delete[] pScene->mMeshes; pScene->mNumMeshes = (unsigned int)avList.size();