void Skeleton::traverseNodes( const NodeRef& node, std::function<void(NodeRef)> visit ) const { visit( node ); for( NodeRef child : node->getChildren() ) { traverseNodes(child, visit); } }
void cloneTraversal( const NodeRef& origin, NodeRef& copy ) { for( const auto& originChild : origin->getChildren() ) { NodeRef copyChild = originChild->clone(); copyChild->setParent( copy ); copy->addChild( copyChild ); cloneTraversal( originChild, copyChild ); } }
NodeRef Skeleton::findNode( const std::string& name, const NodeRef& node ) const { if( node->getName() == name ) { return node; } for( const NodeRef& child : node->getChildren() ) { NodeRef foundNode = findNode( name, child ); if (foundNode != nullptr) { return foundNode; } } return nullptr; }