summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-08-05 11:42:47 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-08-05 11:58:13 -0300
commitd5d83b754d1d3f73e6c5d02671fef32aaeac5a40 (patch)
tree14227254b72a4b902a899d54b4a976d7b4513c5e /scene/resources
parent464d59935dccd558e54f30de24c9ad8ce4e7b686 (diff)
Ensure index is only saved when scene is inherited, or parent node is not from the edited scene. Closes #17562.
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/packed_scene.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 446b2b0e68..07783d5f4a 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -395,7 +395,15 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
nd.name = _nm_get_string(p_node->get_name(), name_map);
nd.instance = -1; //not instanced by default
- nd.index = p_node->get_index();
+
+ //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)))) {
+ //do not save index, because it belongs to saved scene and scene is not inherited
+ nd.index = -1;
+ } else {
+ //part of an inherited scene, or parent is from an instanced scene
+ nd.index = p_node->get_index();
+ }
// if this node is part of an instanced scene or sub-instanced scene
// we need to get the corresponding instance states.