From 98e98dc40c32d19cc7f6d6ba0dfb451344442dcf Mon Sep 17 00:00:00 2001 From: Daniel Hritzkiv Date: Wed, 29 Nov 2017 12:20:09 -0500 Subject: [PATCH] Fix node names sharing same name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- code/glTF2Importer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/glTF2Importer.cpp b/code/glTF2Importer.cpp index ca12d3657..94e5ca3f1 100644 --- a/code/glTF2Importer.cpp +++ b/code/glTF2Importer.cpp @@ -516,7 +516,9 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector& { 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());