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");
|
ASSIMP_LOG_DEBUG("RemoveRedundantMatsProcess begin");
|
||||||
|
|
||||||
unsigned int redundantRemoved = 0, unreferencedRemoved = 0;
|
unsigned int redundantRemoved = 0, unreferencedRemoved = 0;
|
||||||
if (pScene->mNumMaterials) {
|
if (pScene->mNumMaterials == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Find out which materials are referenced by meshes
|
// Find out which materials are referenced by meshes
|
||||||
std::vector<bool> abReferenced(pScene->mNumMaterials,false);
|
std::vector<bool> abReferenced(pScene->mNumMaterials,false);
|
||||||
for (unsigned int i = 0;i < pScene->mNumMeshes;++i)
|
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,
|
// If the new material count differs from the original,
|
||||||
// we need to rebuild the material list and remap mesh material indexes.
|
// we need to rebuild the material list and remap mesh material indexes.
|
||||||
if(iNewNum < 1)
|
if (iNewNum < 1) {
|
||||||
throw DeadlyImportError("No materials remaining");
|
//throw DeadlyImportError("No materials remaining");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (iNewNum != pScene->mNumMaterials) {
|
if (iNewNum != pScene->mNumMaterials) {
|
||||||
ai_assert(iNewNum > 0);
|
ai_assert(iNewNum > 0);
|
||||||
aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];
|
aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];
|
||||||
|
@ -192,7 +197,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) {
|
||||||
// delete temporary storage
|
// delete temporary storage
|
||||||
delete[] aiHashes;
|
delete[] aiHashes;
|
||||||
delete[] aiMappingTable;
|
delete[] aiMappingTable;
|
||||||
}
|
|
||||||
if (redundantRemoved == 0 && unreferencedRemoved == 0) {
|
if (redundantRemoved == 0 && unreferencedRemoved == 0) {
|
||||||
ASSIMP_LOG_DEBUG("RemoveRedundantMatsProcess finished ");
|
ASSIMP_LOG_DEBUG("RemoveRedundantMatsProcess finished ");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue