瀏覽代碼

Merge pull request #2353 from phr34k/fix-bug-autogenerated-names

Fix automatic name assignment for ColladaLoader when using name based assignment
Kim Kulling 6 年之前
父節點
當前提交
b7906bcce9
共有 1 個文件被更改,包括 20 次插入13 次删除
  1. 20 13
      code/ColladaLoader.cpp

+ 20 - 13
code/ColladaLoader.cpp

@@ -1926,21 +1926,28 @@ const Collada::Node* ColladaLoader::FindNodeBySID( const Collada::Node* pNode, c
 std::string ColladaLoader::FindNameForNode( const Collada::Node* pNode)
 std::string ColladaLoader::FindNameForNode( const Collada::Node* pNode)
 {
 {
     // If explicitly requested, just use the collada name.
     // If explicitly requested, just use the collada name.
-    if (useColladaName) {
-        return pNode->mName;
+    if (useColladaName)
+    {
+        if (!pNode->mName.empty()) {
+            return pNode->mName;
+        } else {
+            return format() << "$ColladaAutoName$_" << mNodeNameCounter++;
+        }
     }
     }
-
-    // Now setup the name of the assimp node. The collada name might not be
-    // unique, so we use the collada ID.
-    if (!pNode->mID.empty())
-        return pNode->mID;
-    else if (!pNode->mSID.empty())
-    return pNode->mSID;
-  else
+    else
     {
     {
-        // No need to worry. Unnamed nodes are no problem at all, except
-        // if cameras or lights need to be assigned to them.
-    return format() << "$ColladaAutoName$_" << mNodeNameCounter++;
+        // Now setup the name of the assimp node. The collada name might not be
+        // unique, so we use the collada ID.
+        if (!pNode->mID.empty())
+            return pNode->mID;
+        else if (!pNode->mSID.empty())
+            return pNode->mSID;
+        else
+        {
+            // No need to worry. Unnamed nodes are no problem at all, except
+            // if cameras or lights need to be assigned to them.
+            return format() << "$ColladaAutoName$_" << mNodeNameCounter++;
+        }
     }
     }
 }
 }