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]); } } diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index 91f0dc906..c4b6c815f 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -185,12 +185,12 @@ void Converter::ConvertNodes( uint64_t id, aiNode& parent, const aiMatrix4x4& pa } if ( !name_carrier ) { - NodeNameCache::const_iterator it( std::find( mNodeNames.begin(), mNodeNames.end(), original_name ) ); + NodeNameCache::const_iterator it = mNodeNames.find(original_name); if ( it != mNodeNames.end() ) { original_name = original_name + std::string( "001" ); } - mNodeNames.push_back( original_name ); + mNodeNames.insert( original_name ); nodes_chain.push_back( new aiNode( original_name ) ); } else { original_name = nodes_chain.back()->mName.C_Str(); @@ -398,30 +398,18 @@ void Converter::ConvertCamera( const Camera& cam, const std::string &orig_name ) out_camera->mClipPlaneFar = cam.FarPlane(); } -static bool HasName( NodeNameCache &cache, const std::string &name ) { - NodeNameCache::const_iterator it( std::find( cache.begin(), cache.end(), name ) ); - return it != cache.end(); - -} -void Converter::GetUniqueName( const std::string &name, std::string &uniqueName ) { - if ( !HasName( mNodeNames, name ) ) { - uniqueName = name; - mNodeNames.push_back( uniqueName ); - return; - } - - int i( 0 ); - std::string newName( name ); - while ( HasName( mNodeNames, newName ) ) { +void Converter::GetUniqueName( const std::string &name, std::string &uniqueName ) +{ + int i = 0; + uniqueName = name; + while (mNodeNames.find(uniqueName) != mNodeNames.end()) + { ++i; - newName.clear(); - newName += name; std::stringstream ext; - ext << std::setfill( '0' ) << std::setw( 3 ) << i; - newName += ext.str(); + ext << name << std::setfill('0') << std::setw(3) << i; + uniqueName = ext.str(); } - uniqueName = newName; - mNodeNames.push_back( uniqueName ); + mNodeNames.insert(uniqueName); } diff --git a/code/FBXConverter.h b/code/FBXConverter.h index 2c0810d94..b6654e378 100644 --- a/code/FBXConverter.h +++ b/code/FBXConverter.h @@ -68,7 +68,7 @@ namespace FBX { class Document; -using NodeNameCache = std::vector; +using NodeNameCache = std::set; /** * Convert a FBX #Document to #aiScene