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 ); } }
void Node::insertChildAt( NodeRef child, size_t index ) { Node *former_parent = child->getParent(); if( former_parent ) // remove child from parent (but skip notifying child) { vector_remove( &former_parent->mChildren, child ); } child->setParent( this ); mChildren.insert( mChildren.begin() + index, child ); childAdded( child ); }
void Node::addChild( NodeRef node ) { if( node && !hasChild( node ) ) { // remove child from current parent NodeRef parent = node->getParent(); if( parent ) parent->removeChild( node ); // add to children mChildren.push_back( node ); // set parent node->setParent( shared_from_this() ); // store nodes in lookup table if not done yet uuidLookup[mUuid] = NodeWeakRef( shared_from_this() ); uuidLookup[node->mUuid] = NodeWeakRef( node ); } }