Explorar o código

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
Daniel Hritzkiv %!s(int64=7) %!d(string=hai) anos
pai
achega
98e98dc40c
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      code/glTF2Importer.cpp

+ 3 - 1
code/glTF2Importer.cpp

@@ -516,7 +516,9 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
 {
     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()) {
         ainode->mNumChildren = unsigned(node.children.size());