even more efficient
parent
b957d44943
commit
13bba4fb4c
|
@ -442,15 +442,17 @@ 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;
|
||||||
int i = 0;
|
auto it_pair = mNodeNameInstances.insert({ name, 0 }); // duplicate node name instance count
|
||||||
while (mNodeNames.find(uniqueName) != mNodeNames.end())
|
unsigned int& i = it_pair.first->second;
|
||||||
|
auto uniqueIt_pair = mNodeNames.insert(uniqueName);
|
||||||
|
while (!uniqueIt_pair.second)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
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();
|
||||||
|
uniqueIt_pair = mNodeNames.insert(uniqueName);
|
||||||
}
|
}
|
||||||
mNodeNames.insert(uniqueName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* FBXConverter::NameTransformationComp(TransformationComp comp) {
|
const char* FBXConverter::NameTransformationComp(TransformationComp comp) {
|
||||||
|
|
|
@ -461,6 +461,10 @@ private:
|
||||||
using NodeAnimBitMap = std::map<std::string, unsigned int> ;
|
using NodeAnimBitMap = std::map<std::string, unsigned int> ;
|
||||||
NodeAnimBitMap node_anim_chain_bits;
|
NodeAnimBitMap node_anim_chain_bits;
|
||||||
|
|
||||||
|
// number of nodes with the same name
|
||||||
|
using NodeAnimNameMap = std::unordered_map<std::string, unsigned int>;
|
||||||
|
NodeAnimNameMap mNodeNameInstances;
|
||||||
|
|
||||||
using NodeNameCache = std::unordered_set<std::string>;
|
using NodeNameCache = std::unordered_set<std::string>;
|
||||||
NodeNameCache mNodeNames;
|
NodeNameCache mNodeNames;
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ TEST_F(utFBXImporterExporter, importCubesComplexTransform) {
|
||||||
ASSERT_STREQ(child1->mName.C_Str(), "Cube3");
|
ASSERT_STREQ(child1->mName.C_Str(), "Cube3");
|
||||||
|
|
||||||
auto parent = child1;
|
auto parent = child1;
|
||||||
constexpr size_t chain_length = 8u;
|
const size_t chain_length = 8u;
|
||||||
const char* chainStr[chain_length] = {
|
const char* chainStr[chain_length] = {
|
||||||
"Cube1001_$AssimpFbx$_Translation",
|
"Cube1001_$AssimpFbx$_Translation",
|
||||||
"Cube1001_$AssimpFbx$_RotationPivot",
|
"Cube1001_$AssimpFbx$_RotationPivot",
|
||||||
|
|
Loading…
Reference in New Issue