Fix node names sharing same name

Uses node name if it is set, and globally unique id otherwise.

This may still break in some models (glTF2 spec doesn’t guaruntee name values to be unique). However, I couldn’t cause it to break any further using gltf2 models on hand.

Closes #1600
pull/1603/head
Daniel Hritzkiv 2017-11-29 12:20:09 -05:00
parent 5c9ed540b2
commit 98e98dc40c
No known key found for this signature in database
GPG Key ID: D1D19875679D5CBF
1 changed files with 3 additions and 1 deletions

View File

@ -516,7 +516,9 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
{ {
Node& node = *ptr; Node& node = *ptr;
aiNode* ainode = new aiNode(node.name); std::string nameOrId = node.name.empty() ? node.id : node.name;
aiNode* ainode = new aiNode(nameOrId);
if (!node.children.empty()) { if (!node.children.empty()) {
ainode->mNumChildren = unsigned(node.children.size()); ainode->mNumChildren = unsigned(node.children.size());