One map to rule them all

pull/2469/head
Mike Samsonov 2019-05-21 16:05:38 +01:00
parent 13bba4fb4c
commit 0eec1c1d4a
2 changed files with 5 additions and 9 deletions

View File

@ -442,16 +442,15 @@ namespace Assimp {
void FBXConverter::GetUniqueName(const std::string &name, std::string &uniqueName) void FBXConverter::GetUniqueName(const std::string &name, std::string &uniqueName)
{ {
uniqueName = name; uniqueName = name;
auto it_pair = mNodeNameInstances.insert({ name, 0 }); // duplicate node name instance count auto it_pair = mNodeNames.insert({ name, 0 }); // duplicate node name instance count
unsigned int& i = it_pair.first->second; unsigned int& i = it_pair.first->second;
auto uniqueIt_pair = mNodeNames.insert(uniqueName); while (!it_pair.second)
while (!uniqueIt_pair.second)
{ {
i++; i++;
std::stringstream ext; std::ostringstream 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();
uniqueIt_pair = mNodeNames.insert(uniqueName); it_pair = mNodeNames.insert({ uniqueName, 0 });
} }
} }

View File

@ -462,10 +462,7 @@ private:
NodeAnimBitMap node_anim_chain_bits; NodeAnimBitMap node_anim_chain_bits;
// number of nodes with the same name // number of nodes with the same name
using NodeAnimNameMap = std::unordered_map<std::string, unsigned int>; using NodeNameCache = std::unordered_map<std::string, unsigned int>;
NodeAnimNameMap mNodeNameInstances;
using NodeNameCache = std::unordered_set<std::string>;
NodeNameCache mNodeNames; NodeNameCache mNodeNames;
double anim_fps; double anim_fps;