From cc4531459f3e131623d93dfe62ccc25115f0ca52 Mon Sep 17 00:00:00 2001 From: Daniel Hritzkiv Date: Tue, 31 Oct 2017 15:14:21 -0400 Subject: [PATCH 1/2] Set mNumUVComponents to 0 when deleting texture coordinate sets --- code/FindInvalidDataProcess.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/FindInvalidDataProcess.cpp b/code/FindInvalidDataProcess.cpp index 77915bc4e..60b690844 100644 --- a/code/FindInvalidDataProcess.cpp +++ b/code/FindInvalidDataProcess.cpp @@ -360,10 +360,13 @@ int FindInvalidDataProcess::ProcessMesh (aiMesh* pMesh) // process texture coordinates for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS && pMesh->mTextureCoords[i];++i) { if (ProcessArray(pMesh->mTextureCoords[i],pMesh->mNumVertices,"uvcoords",dirtyMask)) { + pMesh->mNumUVComponents[i] = 0; // delete all subsequent texture coordinate sets. - for (unsigned int a = i+1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a) { - delete[] pMesh->mTextureCoords[a]; pMesh->mTextureCoords[a] = NULL; + for (unsigned int a = i + 1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) { + delete[] pMesh->mTextureCoords[a]; + pMesh->mTextureCoords[a] = NULL; + pMesh->mNumUVComponents[a] = 0; } ret = true; } From e52e44ea07375027db56a5384e342969853bbcaa Mon Sep 17 00:00:00 2001 From: Daniel Hritzkiv Date: Tue, 31 Oct 2017 15:18:08 -0400 Subject: [PATCH 2/2] Formatting --- code/FindInvalidDataProcess.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/code/FindInvalidDataProcess.cpp b/code/FindInvalidDataProcess.cpp index 60b690844..a6cb037b2 100644 --- a/code/FindInvalidDataProcess.cpp +++ b/code/FindInvalidDataProcess.cpp @@ -339,27 +339,28 @@ void FindInvalidDataProcess::ProcessAnimationChannel (aiNodeAnim* anim) int FindInvalidDataProcess::ProcessMesh (aiMesh* pMesh) { bool ret = false; - std::vector dirtyMask(pMesh->mNumVertices,(pMesh->mNumFaces ? true : false)); + std::vector dirtyMask(pMesh->mNumVertices, pMesh->mNumFaces); // Ignore elements that are not referenced by vertices. // (they are, for example, caused by the FindDegenerates step) - for (unsigned int m = 0; m < pMesh->mNumFaces;++m) { + for (unsigned int m = 0; m < pMesh->mNumFaces; ++m) { const aiFace& f = pMesh->mFaces[m]; - for (unsigned int i = 0; i < f.mNumIndices;++i) { + for (unsigned int i = 0; i < f.mNumIndices; ++i) { dirtyMask[f.mIndices[i]] = false; } } // Process vertex positions - if(pMesh->mVertices && ProcessArray(pMesh->mVertices,pMesh->mNumVertices,"positions",dirtyMask)) { + if (pMesh->mVertices && ProcessArray(pMesh->mVertices, pMesh->mNumVertices, "positions", dirtyMask)) { DefaultLogger::get()->error("Deleting mesh: Unable to continue without vertex positions"); + return 2; } // process texture coordinates - for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS && pMesh->mTextureCoords[i];++i) { - if (ProcessArray(pMesh->mTextureCoords[i],pMesh->mNumVertices,"uvcoords",dirtyMask)) { + for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS && pMesh->mTextureCoords[i]; ++i) { + if (ProcessArray(pMesh->mTextureCoords[i], pMesh->mNumVertices, "uvcoords", dirtyMask)) { pMesh->mNumUVComponents[i] = 0; // delete all subsequent texture coordinate sets. @@ -368,6 +369,7 @@ int FindInvalidDataProcess::ProcessMesh (aiMesh* pMesh) pMesh->mTextureCoords[a] = NULL; pMesh->mNumUVComponents[a] = 0; } + ret = true; } }