Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
yahkr committed Jan 5, 2025
1 parent f4b239c commit a56e24d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions editor/gui/scene_tree_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@ void SceneTreeEditor::_update_node_subtree(Node *p_node, TreeItem *p_parent, boo
bool part_of_subscene = false;

if (!display_foreign && p_node->get_owner() != get_scene_node() && p_node != get_scene_node()) {
if ((show_enabled_subscene || can_open_instance) && p_node->get_owner() && (get_scene_node()->is_editable_instance(p_node->get_owner()) || (p_node->has_meta(META_EXPOSED_IN_INSTANCE) && p_node->has_meta(META_EXPOSED_IN_OWNER)))) {
if ((show_enabled_subscene || can_open_instance) && p_node->get_owner() && (get_scene_node()->is_editable_instance(p_node->get_owner()) || p_node->has_meta(META_EXPOSED_IN_OWNER))) {
part_of_subscene = true;
//allow
} else if (p_node->has_exposed_nodes()) {
for (int i = 0; i < p_node->get_child_count(); i++) {
if (!get_scene_node()->is_editable_instance(p_node->get_child(i)->get_owner()) || p_node->get_child(i)->has_meta(META_EXPOSED_IN_INSTANCE)) {
if (p_node->get_child(i)->get_owner() == get_scene_node() || !get_scene_node()->is_editable_instance(p_node->get_child(i)->get_owner()) || p_node->get_child(i)->has_meta(META_EXPOSED_IN_INSTANCE)) {
_update_node_subtree(p_node->get_child(i), p_parent);
}
}
Expand Down Expand Up @@ -372,6 +372,10 @@ void SceneTreeEditor::_update_node_subtree(Node *p_node, TreeItem *p_parent, boo
}
} else {
index = p_node->get_index(false);
// Shift the exposed nodes based on how many siblings already exist to maintain exposed node order.
if (!p_node->get_owner()->is_editable_instance(p_node) && p_node->has_meta(META_EXPOSED_IN_OWNER)) {
index = p_parent->get_child_count() + index;
}
item = tree->create_item(p_parent, index);
}

Expand Down
4 changes: 2 additions & 2 deletions scene/resources/packed_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,14 +790,14 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has
nd.instance = -1; //not instantiated by default

//really convoluted condition, but it basically checks that index is only saved when part of an inherited scene OR the node parent is from the edited scene
if (p_owner->get_scene_inherited_state().is_null() && (p_node == p_owner || (p_node->get_owner() == p_owner && (p_node->get_parent() == p_owner || p_node->get_parent()->get_owner() == p_owner)))) {
if (p_owner->get_scene_inherited_state().is_null() && p_node->get_parent()->get_scene_instance_state().is_null() && (p_node == p_owner || (p_node->get_owner() == p_owner && (p_node->get_parent() == p_owner || p_node->get_parent()->get_owner() == p_owner)))) {
//do not save index, because it belongs to saved scene and scene is not inherited
nd.index = -1;
} else if (p_node == p_owner) {
//This (hopefully) happens if the node is a scene root, so its index is irrelevant.
nd.index = -1;
} else {
//part of an inherited scene, or parent is from an instantiated scene
//part of an inherited scene, or parent is from an instantiated scene, or parent has exposed children so order matters
nd.index = p_node->get_index();
}

Expand Down

0 comments on commit a56e24d

Please sign in to comment.