From 0505dd72661b28b53589ff1cf58074b862064399 Mon Sep 17 00:00:00 2001 From: Matias Date: Wed, 3 Apr 2019 12:19:23 +0200 Subject: [PATCH] issue 2390: FBXConverter::GetUniqueName now uses a map for keeping track of duplicate node name count and a set for registering names that have been taken.This is required because the model might contain a several nodes called "nodename" and another one called "nodename001". In that case we can't add "001" to the second node called "nodename". --- code/FBXConverter.cpp | 16 ++++++++++------ code/FBXConverter.h | 8 ++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index 692f081da..a654bc870 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -412,18 +412,22 @@ namespace Assimp { { uniqueName = name; int i = 0; - auto it = mNodeNameInstances.find(uniqueName); + auto it = mNodeNameInstances.find(name); // duplicate node name instance count if (it != mNodeNameInstances.end()) { - i = it->second + 1; - std::stringstream ext; - ext << name << std::setfill('0') << std::setw(3) << i; - uniqueName = ext.str(); + i = it->second; + while (mNodeNames.find(uniqueName) != mNodeNames.end()) + { + i++; + std::stringstream ext; + ext << name << std::setfill('0') << std::setw(3) << i; + uniqueName = ext.str(); + } } mNodeNameInstances[name] = i; + mNodeNames.insert(uniqueName); } - const char* FBXConverter::NameTransformationComp(TransformationComp comp) { switch (comp) { case TransformationComp_Translation: diff --git a/code/FBXConverter.h b/code/FBXConverter.h index 8c31fba31..162cf6e94 100644 --- a/code/FBXConverter.h +++ b/code/FBXConverter.h @@ -59,6 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include struct aiScene; struct aiNode; @@ -442,8 +443,11 @@ private: NodeAnimBitMap node_anim_chain_bits; // number of nodes with the same name - using NodeNameMap = std::unordered_map ; - NodeNameMap mNodeNameInstances; + typedef std::unordered_map NodeAnimNameMap; + NodeAnimNameMap mNodeNameInstances; + + typedef std::unordered_set NodeNameCache; + NodeNameCache mNodeNames; double anim_fps;