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".
parent
3ea9216c6e
commit
0505dd7266
|
@ -412,17 +412,21 @@ namespace Assimp {
|
||||||
{
|
{
|
||||||
uniqueName = name;
|
uniqueName = name;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
auto it = mNodeNameInstances.find(uniqueName);
|
auto it = mNodeNameInstances.find(name); // duplicate node name instance count
|
||||||
if (it != mNodeNameInstances.end())
|
if (it != mNodeNameInstances.end())
|
||||||
{
|
{
|
||||||
i = it->second + 1;
|
i = it->second;
|
||||||
|
while (mNodeNames.find(uniqueName) != mNodeNames.end())
|
||||||
|
{
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
mNodeNameInstances[name] = i;
|
|
||||||
}
|
}
|
||||||
|
mNodeNameInstances[name] = i;
|
||||||
|
mNodeNames.insert(uniqueName);
|
||||||
|
}
|
||||||
|
|
||||||
const char* FBXConverter::NameTransformationComp(TransformationComp comp) {
|
const char* FBXConverter::NameTransformationComp(TransformationComp comp) {
|
||||||
switch (comp) {
|
switch (comp) {
|
||||||
|
|
|
@ -59,6 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/camera.h>
|
#include <assimp/camera.h>
|
||||||
#include <assimp/StringComparison.h>
|
#include <assimp/StringComparison.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
struct aiScene;
|
struct aiScene;
|
||||||
struct aiNode;
|
struct aiNode;
|
||||||
|
@ -442,8 +443,11 @@ 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 NodeNameMap = std::unordered_map<std::string, unsigned int> ;
|
typedef std::unordered_map<std::string, unsigned int> NodeAnimNameMap;
|
||||||
NodeNameMap mNodeNameInstances;
|
NodeAnimNameMap mNodeNameInstances;
|
||||||
|
|
||||||
|
typedef std::unordered_set<std::string> NodeNameCache;
|
||||||
|
NodeNameCache mNodeNames;
|
||||||
|
|
||||||
double anim_fps;
|
double anim_fps;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue