| 154 | {} |
| 155 | |
| 156 | bool pre(const scene::INodePtr& originalNode) override |
| 157 | { |
| 158 | // The removeChildNode below might destroy the instance - push the refcount |
| 159 | scene::INodePtr node = originalNode; |
| 160 | |
| 161 | // greebo: Check if the visited node is the worldspawn of the other map |
| 162 | if (Node_isWorldspawn(node)) |
| 163 | { |
| 164 | // Find the worldspawn of the target map |
| 165 | const scene::INodePtr& worldSpawn = GlobalMap().getWorldspawn(); |
| 166 | |
| 167 | if (!worldSpawn) |
| 168 | { |
| 169 | // Set the worldspawn to the new node |
| 170 | GlobalMap().setWorldspawn(node); |
| 171 | |
| 172 | // greebo: Un-register the node from its previous parent first to be clean |
| 173 | scene::INodePtr oldParent = node->getParent(); |
| 174 | |
| 175 | if (oldParent) |
| 176 | { |
| 177 | oldParent->removeChildNode(node); |
| 178 | } |
| 179 | |
| 180 | // Insert the visited node at the target path |
| 181 | _path.top()->addChildNode(node); |
| 182 | |
| 183 | _path.push(node); |
| 184 | |
| 185 | // Select all the children of the visited node (these are primitives) |
| 186 | node->foreachNode([](const scene::INodePtr& child)->bool |
| 187 | { |
| 188 | Node_setSelected(child, true); |
| 189 | return true; |
| 190 | }); |
| 191 | } |
| 192 | else |
| 193 | { |
| 194 | // The target map already has a worldspawn |
| 195 | _path.push(worldSpawn); |
| 196 | |
| 197 | // Move all children of this node to the target worldspawn |
| 198 | PrimitiveMerger visitor(worldSpawn); |
| 199 | node->traverseChildren(visitor); |
| 200 | } |
| 201 | } |
| 202 | else |
| 203 | { |
| 204 | // This is an ordinary entity, not worldspawn |
| 205 | |
| 206 | // greebo: Un-register the entity from its previous root node first to be clean |
| 207 | scene::INodePtr oldParent = node->getParent(); |
| 208 | |
| 209 | if (oldParent) |
| 210 | { |
| 211 | oldParent->removeChildNode(node); |
| 212 | } |
| 213 |
nothing calls this directly
no test coverage detected