Kimkulling/fix bahavior of remove redundat mats issue 5438 (#5451)
* Fix crash in viewer * Fix bevavior when material was not referencedpull/5372/head^2
parent
3476c79801
commit
3990ec80a1
|
@ -75,7 +75,10 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) {
|
|||
ASSIMP_LOG_DEBUG("RemoveRedundantMatsProcess begin");
|
||||
|
||||
unsigned int redundantRemoved = 0, unreferencedRemoved = 0;
|
||||
if (pScene->mNumMaterials) {
|
||||
if (pScene->mNumMaterials == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find out which materials are referenced by meshes
|
||||
std::vector<bool> abReferenced(pScene->mNumMaterials,false);
|
||||
for (unsigned int i = 0;i < pScene->mNumMeshes;++i)
|
||||
|
@ -153,8 +156,10 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) {
|
|||
}
|
||||
// If the new material count differs from the original,
|
||||
// we need to rebuild the material list and remap mesh material indexes.
|
||||
if(iNewNum < 1)
|
||||
throw DeadlyImportError("No materials remaining");
|
||||
if (iNewNum < 1) {
|
||||
//throw DeadlyImportError("No materials remaining");
|
||||
return;
|
||||
}
|
||||
if (iNewNum != pScene->mNumMaterials) {
|
||||
ai_assert(iNewNum > 0);
|
||||
aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];
|
||||
|
@ -192,7 +197,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) {
|
|||
// delete temporary storage
|
||||
delete[] aiHashes;
|
||||
delete[] aiMappingTable;
|
||||
}
|
||||
|
||||
if (redundantRemoved == 0 && unreferencedRemoved == 0) {
|
||||
ASSIMP_LOG_DEBUG("RemoveRedundantMatsProcess finished ");
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue