Pārlūkot izejas kodu

Merge pull request #662 from dgough/next

Fixed Node::findNodes() so that it searches the MeshSkin too
Sean Paul Taylor 13 gadi atpakaļ
vecāks
revīzija
2638aff5a6
1 mainītis faili ar 12 papildinājumiem un 0 dzēšanām
  1. 12 0
      gameplay/src/Node.cpp

+ 12 - 0
gameplay/src/Node.cpp

@@ -337,6 +337,18 @@ unsigned int Node::findNodes(const char* id, std::vector<Node*>& nodes, bool rec
     
     unsigned int count = 0;
 
+    // If the node has a model with a mesh skin, search the skin's hierarchy as well.
+    Node* rootNode = NULL;
+    if (_model != NULL && _model->getSkin() != NULL && (rootNode = _model->getSkin()->_rootNode) != NULL)
+    {
+        if ((exactMatch && rootNode->_id == id) || (!exactMatch && rootNode->_id.find(id) == 0))
+        {
+            nodes.push_back(rootNode);
+            ++count;
+        }
+        count += rootNode->findNodes(id, nodes, true, exactMatch);
+    }
+
     // Search immediate children first.
     for (Node* child = getFirstChild(); child != NULL; child = child->getNextSibling())
     {