From b965e7a6dc7aeea26af1ae239bfae707b492869b Mon Sep 17 00:00:00 2001 From: Sebastian Matusik Date: Sat, 28 Jul 2018 18:18:17 +0100 Subject: [PATCH] FlipUVsProcess should also process AnimMeshes (if any) --- code/ConvertToLHProcess.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/code/ConvertToLHProcess.cpp b/code/ConvertToLHProcess.cpp index 37ba970e4..9cb45cc69 100644 --- a/code/ConvertToLHProcess.cpp +++ b/code/ConvertToLHProcess.cpp @@ -59,6 +59,25 @@ using namespace Assimp; #ifndef ASSIMP_BUILD_NO_MAKELEFTHANDED_PROCESS +namespace { + +template +void flipUVs(aiMeshType* pMesh) { + if (pMesh == nullptr) { return; } + // mirror texture y coordinate + for (unsigned int tcIdx = 0; tcIdx < AI_MAX_NUMBER_OF_TEXTURECOORDS; tcIdx++) { + if (!pMesh->HasTextureCoords(tcIdx)) { + break; + } + + for (unsigned int vIdx = 0; vIdx < pMesh->mNumVertices; vIdx++) { + pMesh->mTextureCoords[tcIdx][vIdx].y = 1.0f - pMesh->mTextureCoords[tcIdx][vIdx].y; + } + } +} + +} // namespace + // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer MakeLeftHandedProcess::MakeLeftHandedProcess() @@ -282,15 +301,9 @@ void FlipUVsProcess::ProcessMaterial (aiMaterial* _mat) // Converts a single mesh void FlipUVsProcess::ProcessMesh( aiMesh* pMesh) { - // mirror texture y coordinate - for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) { - if( !pMesh->HasTextureCoords( a ) ) { - break; - } - - for( unsigned int b = 0; b < pMesh->mNumVertices; b++ ) { - pMesh->mTextureCoords[ a ][ b ].y = 1.0f - pMesh->mTextureCoords[ a ][ b ].y; - } + flipUVs(pMesh); + for (unsigned int idx = 0; idx < pMesh->mNumAnimMeshes; idx++) { + flipUVs(pMesh->mAnimMeshes[idx]); } }