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;