Răsfoiți Sursa

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 7 ani în urmă
părinte
comite
98e98dc40c
1 a modificat fișierele cu 3 adăugiri și 1 ștergeri
  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());