FBX: Fix for loading taking a very long time on models with many duplicate names (issue_2390)
parent
a43ac5b3fd
commit
ca08c4a209
|
@ -410,16 +410,17 @@ namespace Assimp {
|
||||||
|
|
||||||
void FBXConverter::GetUniqueName(const std::string &name, std::string &uniqueName)
|
void FBXConverter::GetUniqueName(const std::string &name, std::string &uniqueName)
|
||||||
{
|
{
|
||||||
int i = 0;
|
|
||||||
uniqueName = name;
|
uniqueName = name;
|
||||||
while (mNodeNames.find(uniqueName) != mNodeNames.end())
|
int i = 0;
|
||||||
|
auto it = mNodeNameInstances.find(uniqueName);
|
||||||
|
if (it != mNodeNameInstances.end())
|
||||||
{
|
{
|
||||||
++i;
|
i = it->second + 1;
|
||||||
std::stringstream ext;
|
std::stringstream ext;
|
||||||
ext << name << std::setfill('0') << std::setw(3) << i;
|
ext << name << std::setfill('0') << std::setw(3) << i;
|
||||||
uniqueName = ext.str();
|
uniqueName = ext.str();
|
||||||
}
|
}
|
||||||
mNodeNames.insert(uniqueName);
|
mNodeNameInstances[name] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/texture.h>
|
#include <assimp/texture.h>
|
||||||
#include <assimp/camera.h>
|
#include <assimp/camera.h>
|
||||||
#include <assimp/StringComparison.h>
|
#include <assimp/StringComparison.h>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
struct aiScene;
|
struct aiScene;
|
||||||
struct aiNode;
|
struct aiNode;
|
||||||
|
@ -74,8 +75,6 @@ namespace FBX {
|
||||||
|
|
||||||
class Document;
|
class Document;
|
||||||
|
|
||||||
using NodeNameCache = std::set<std::string>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a FBX #Document to #aiScene
|
* Convert a FBX #Document to #aiScene
|
||||||
* @param out Empty scene to be populated
|
* @param out Empty scene to be populated
|
||||||
|
@ -444,7 +443,10 @@ private:
|
||||||
typedef std::map<std::string, unsigned int> NodeAnimBitMap;
|
typedef std::map<std::string, unsigned int> NodeAnimBitMap;
|
||||||
NodeAnimBitMap node_anim_chain_bits;
|
NodeAnimBitMap node_anim_chain_bits;
|
||||||
|
|
||||||
NodeNameCache mNodeNames;
|
// number of nodes with the same name
|
||||||
|
typedef std::unordered_map<std::string, unsigned int> NodeNameMap;
|
||||||
|
NodeNameMap mNodeNameInstances;
|
||||||
|
|
||||||
double anim_fps;
|
double anim_fps;
|
||||||
|
|
||||||
aiScene* const out;
|
aiScene* const out;
|
||||||
|
|
Loading…
Reference in New Issue