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".

pull/2391/head
Matias 2019-04-03 12:19:23 +02:00
parent 3ea9216c6e
commit 0505dd7266
2 changed files with 16 additions and 8 deletions

View File

@ -412,17 +412,21 @@ 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;
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;
}
mNodeNameInstances[name] = i;
mNodeNames.insert(uniqueName);
}
const char* FBXConverter::NameTransformationComp(TransformationComp comp) {
switch (comp) {

View File

@ -59,6 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/camera.h>
#include <assimp/StringComparison.h>
#include <unordered_map>
#include <unordered_set>
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<std::string, unsigned int> ;
NodeNameMap mNodeNameInstances;
typedef std::unordered_map<std::string, unsigned int> NodeAnimNameMap;
NodeAnimNameMap mNodeNameInstances;
typedef std::unordered_set<std::string> NodeNameCache;
NodeNameCache mNodeNames;
double anim_fps;