From 6e090c88b8ab0fcdc194a896ca2338a8ed33a749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 7 Dec 2021 12:13:31 +0100 Subject: [PATCH 1/2] fix index variable for surfaces Closes: https://github.com/assimp/assimp/issues/4209 --- code/AssetLib/LWO/LWOLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/LWO/LWOLoader.cpp b/code/AssetLib/LWO/LWOLoader.cpp index bc62152c5..801da1d60 100644 --- a/code/AssetLib/LWO/LWOLoader.cpp +++ b/code/AssetLib/LWO/LWOLoader.cpp @@ -393,7 +393,7 @@ void LWOImporter::InternReadFile(const std::string &pFile, // If a RGB color map is explicitly requested delete the // alpha channel - it could theoretically be != 1. - if (_mSurfaces[i].mVCMapType == AI_LWO_RGB) + if (_mSurfaces[j].mVCMapType == AI_LWO_RGB) pvVC[w]->a = 1.f; pvVC[w]++; From 9a7ee0ac14b1de24c3793c3d4ba6fdb1310cbec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 7 Dec 2021 12:35:15 +0100 Subject: [PATCH 2/2] Throw a DeadlyImportError rather than an assertion if all materials are redundant and thus removed Closes: https://github.com/assimp/assimp/issues/4224 Closes: https://github.com/assimp/assimp/issues/4225 --- code/PostProcessing/RemoveRedundantMaterials.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/PostProcessing/RemoveRedundantMaterials.cpp b/code/PostProcessing/RemoveRedundantMaterials.cpp index 36745fb1d..f6355fcc6 100644 --- a/code/PostProcessing/RemoveRedundantMaterials.cpp +++ b/code/PostProcessing/RemoveRedundantMaterials.cpp @@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "ProcessHelper.h" #include "Material/MaterialSystem.h" +#include #include using namespace Assimp; @@ -171,6 +172,8 @@ 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 != pScene->mNumMaterials) { ai_assert(iNewNum > 0); aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];