Merge branch 'master' into master

pull/2071/head
Kim Kulling 2018-08-02 21:06:19 +02:00 committed by GitHub
commit 63460d7f20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 33 deletions

View File

@ -59,6 +59,25 @@ using namespace Assimp;
#ifndef ASSIMP_BUILD_NO_MAKELEFTHANDED_PROCESS #ifndef ASSIMP_BUILD_NO_MAKELEFTHANDED_PROCESS
namespace {
template <typename aiMeshType>
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 // Constructor to be privately used by Importer
MakeLeftHandedProcess::MakeLeftHandedProcess() MakeLeftHandedProcess::MakeLeftHandedProcess()
@ -282,15 +301,9 @@ void FlipUVsProcess::ProcessMaterial (aiMaterial* _mat)
// Converts a single mesh // Converts a single mesh
void FlipUVsProcess::ProcessMesh( aiMesh* pMesh) void FlipUVsProcess::ProcessMesh( aiMesh* pMesh)
{ {
// mirror texture y coordinate flipUVs(pMesh);
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) { for (unsigned int idx = 0; idx < pMesh->mNumAnimMeshes; idx++) {
if( !pMesh->HasTextureCoords( a ) ) { flipUVs(pMesh->mAnimMeshes[idx]);
break;
}
for( unsigned int b = 0; b < pMesh->mNumVertices; b++ ) {
pMesh->mTextureCoords[ a ][ b ].y = 1.0f - pMesh->mTextureCoords[ a ][ b ].y;
}
} }
} }

View File

@ -185,12 +185,12 @@ void Converter::ConvertNodes( uint64_t id, aiNode& parent, const aiMatrix4x4& pa
} }
if ( !name_carrier ) { 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() ) { if ( it != mNodeNames.end() ) {
original_name = original_name + std::string( "001" ); original_name = original_name + std::string( "001" );
} }
mNodeNames.push_back( original_name ); mNodeNames.insert( original_name );
nodes_chain.push_back( new aiNode( original_name ) ); nodes_chain.push_back( new aiNode( original_name ) );
} else { } else {
original_name = nodes_chain.back()->mName.C_Str(); 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(); out_camera->mClipPlaneFar = cam.FarPlane();
} }
static bool HasName( NodeNameCache &cache, const std::string &name ) { void Converter::GetUniqueName( const std::string &name, std::string &uniqueName )
NodeNameCache::const_iterator it( std::find( cache.begin(), cache.end(), name ) ); {
return it != cache.end(); int i = 0;
uniqueName = name;
} while (mNodeNames.find(uniqueName) != mNodeNames.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 ) ) {
++i; ++i;
newName.clear();
newName += name;
std::stringstream ext; std::stringstream ext;
ext << std::setfill( '0' ) << std::setw( 3 ) << i; ext << name << std::setfill('0') << std::setw(3) << i;
newName += ext.str(); uniqueName = ext.str();
} }
uniqueName = newName; mNodeNames.insert(uniqueName);
mNodeNames.push_back( uniqueName );
} }

View File

@ -68,7 +68,7 @@ namespace FBX {
class Document; class Document;
using NodeNameCache = std::vector<std::string>; using NodeNameCache = std::set<std::string>;
/** /**
* Convert a FBX #Document to #aiScene * Convert a FBX #Document to #aiScene