void Node::addChild(Node* node) { if (node != 0) { if (!containsChild(node)) { node->setParent(this); _children.append(node); } } };
void Node::addChildren(QList<Node*> nodes) { for (int i = 0; i < nodes.count(); i++) { if (!containsChild(nodes.at(i))) { nodes.at(i)->setParent(this); _children.append(nodes.at(i)); } } };
//------------------------------------------------------------------------------ Entity * Entity::addChild(Entity * child) { #ifdef SN_BUILD_DEBUG if (child->getParent() != this) { SN_WARNING("Entity::addChild: parent is not matching with " << toString()); } if (containsChild(child)) { SN_ERROR("Entity::addChild: " << child->toString() << " already contained in entity " << toString()); return nullptr; } #endif m_children.push_back(child); //if (childIndex == -1) // m_children.push_back(child); //else //{ // if (childIndex >= m_children.size()) // m_children.resize(childIndex + 1, nullptr); // m_children[childIndex] = child; //} return child; }