| 79 | } |
| 80 | |
| 81 | void ParentPrimitivesToEntityWalker::reparent() |
| 82 | { |
| 83 | for (const scene::INodePtr& i : _childrenToReparent) |
| 84 | { |
| 85 | // Remove this path from the old parent |
| 86 | scene::removeNodeFromParent(i); |
| 87 | |
| 88 | // Insert the child node into the parent node |
| 89 | _parent->addChildNode(i); |
| 90 | } |
| 91 | |
| 92 | rMessage() << "Reparented " << _childrenToReparent.size() |
| 93 | << " primitives." << std::endl; |
| 94 | |
| 95 | // Update parent node/subgraph visibility after reparenting |
| 96 | scene::UpdateNodeVisibilityWalker updater(_parent->getRootNode()->getLayerManager()); |
| 97 | |
| 98 | // Update the new parent too |
| 99 | _parent->traverse(updater); |
| 100 | |
| 101 | for (const scene::INodePtr& i : _oldParents) |
| 102 | { |
| 103 | i->traverse(updater); |
| 104 | } |
| 105 | |
| 106 | // Now check if any parents were left behind empty |
| 107 | for (const scene::INodePtr& oldParent : _oldParents) |
| 108 | { |
| 109 | if (!scene::hasChildPrimitives(oldParent)) |
| 110 | { |
| 111 | // Is empty, but make sure we're not removing the worldspawn |
| 112 | if (Node_isWorldspawn(oldParent)) continue; |
| 113 | |
| 114 | // Is empty now, remove it |
| 115 | scene::removeNodeFromParent(oldParent); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | // Update the scene |
| 120 | SceneChangeNotify(); |
| 121 | } |
| 122 | |
| 123 | void ParentPrimitivesToEntityWalker::selectReparentedPrimitives() |
| 124 | { |
no test coverage detected