MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _update_node_subtree

Method _update_node_subtree

editor/scene/scene_tree_editor.cpp:282–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282void SceneTreeEditor::_update_node_subtree(Node *p_node, TreeItem *p_parent, bool p_force) {
283 if (!p_node) {
284 return;
285 }
286
287 // Only owned nodes are editable, since nodes can create their own (manually owned) child nodes,
288 // which the editor needs not to know about.
289
290 bool part_of_subscene = false;
291
292 if (!display_foreign && p_node->get_owner() != get_scene_node() && p_node != get_scene_node()) {
293 if ((show_enabled_subscene || can_open_instance) && p_node->get_owner() && (get_scene_node()->is_editable_instance(p_node->get_owner()))) {
294 part_of_subscene = true;
295 // Allow.
296 } else {
297 // Stale node, remove recursively.
298 node_cache.remove(p_node, true);
299 return;
300 }
301 } else {
302 part_of_subscene = p_node != get_scene_node() && get_scene_node()->get_scene_inherited_state().is_valid() && get_scene_node()->get_scene_inherited_state()->find_node_by_path(get_scene_node()->get_path_to(p_node)) >= 0;
303 }
304
305 HashMap<Node *, CachedNode>::Iterator I = node_cache.get(p_node);
306 TreeItem *item = nullptr;
307
308 bool is_new = false;
309
310 if (I) {
311 item = I->value.item;
312 TreeItem *current_parent = item->get_parent();
313
314 // Our parent might be re-created because of a changed type.
315 if (p_parent && p_parent != current_parent) {
316 if (current_parent) {
317 current_parent->remove_child(item);
318 }
319 p_parent->add_child(item);
320 I->value.removed = false;
321 _move_node_item(p_parent, I);
322 }
323
324 if (I->value.has_moved_children) {
325 _move_node_children(I);
326 }
327 } else {
328 int index = -1;
329 // Check to see if there is a root node for us to reuse.
330 if (!p_parent) {
331 item = tree->get_root();
332 if (!item) {
333 item = tree->create_item(nullptr);
334 index = 0;
335 }
336 } else {
337 index = p_node->get_index(false);
338 item = tree->create_item(p_parent, index);
339 }

Callers

nothing calls this directly

Calls 15

is_editable_instanceMethod · 0.80
get_path_toMethod · 0.80
sizeMethod · 0.65
get_ownerMethod · 0.45
removeMethod · 0.45
is_validMethod · 0.45
find_node_by_pathMethod · 0.45
getMethod · 0.45
get_parentMethod · 0.45
remove_childMethod · 0.45

Tested by

no test coverage detected