summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/node.cpp12
-rw-r--r--scene/main/scene_tree.cpp10
-rw-r--r--scene/main/scene_tree.h3
3 files changed, 16 insertions, 9 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 506dc85475..d8baa7834d 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2114,8 +2114,16 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
node_tree.push_front(this);
if (instanced) {
+ // Since nodes in the instanced hierarchy won't be duplicated explicitly, we need to make an inventory
+ // of all the nodes in the tree of the instanced scene in order to transfer the values of the properties
+
for (List<const Node *>::Element *N = node_tree.front(); N; N = N->next()) {
for (int i = 0; i < N->get()->get_child_count(); ++i) {
+
+ // Skip nodes not really belonging to the instanced hierarchy; they'll be processed normally later
+ if (get_child(i)->data.owner != this)
+ continue;
+
node_tree.push_back(N->get()->get_child(i));
}
}
@@ -2124,6 +2132,7 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
for (List<const Node *>::Element *N = node_tree.front(); N; N = N->next()) {
Node *current_node = node->get_node(get_path_to(N->get()));
+ ERR_CONTINUE(!current_node);
if (p_flags & DUPLICATE_SCRIPTS) {
bool is_valid = false;
@@ -2136,9 +2145,6 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
List<PropertyInfo> plist;
N->get()->get_property_list(&plist);
- if (!current_node)
- continue;
-
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 17abf2425a..f74bf161f0 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -127,7 +127,7 @@ void SceneTree::remove_from_group(const StringName &p_group, Node *p_node) {
group_map.erase(E);
}
-void SceneTree::_flush_transform_notifications() {
+void SceneTree::flush_transform_notifications() {
SelfList<Node> *n = xform_change_list.first();
while (n) {
@@ -448,7 +448,7 @@ bool SceneTree::iteration(float p_time) {
current_frame++;
- _flush_transform_notifications();
+ flush_transform_notifications();
MainLoop::iteration(p_time);
physics_process_time = p_time;
@@ -459,7 +459,7 @@ bool SceneTree::iteration(float p_time) {
_notify_group_pause("physics_process", Node::NOTIFICATION_PHYSICS_PROCESS);
_flush_ugc();
MessageQueue::get_singleton()->flush(); //small little hack
- _flush_transform_notifications();
+ flush_transform_notifications();
call_group_flags(GROUP_CALL_REALTIME, "_viewports", "update_worlds");
root_lock--;
@@ -487,7 +487,7 @@ bool SceneTree::idle(float p_time) {
MessageQueue::get_singleton()->flush(); //small little hack
- _flush_transform_notifications();
+ flush_transform_notifications();
_notify_group_pause("idle_process_internal", Node::NOTIFICATION_INTERNAL_PROCESS);
_notify_group_pause("idle_process", Node::NOTIFICATION_PROCESS);
@@ -503,7 +503,7 @@ bool SceneTree::idle(float p_time) {
_flush_ugc();
MessageQueue::get_singleton()->flush(); //small little hack
- _flush_transform_notifications(); //transforms after world update, to avoid unnecessary enter/exit notifications
+ flush_transform_notifications(); //transforms after world update, to avoid unnecessary enter/exit notifications
call_group_flags(GROUP_CALL_REALTIME, "_viewports", "update_worlds");
root_lock--;
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index bc3efdc42f..7898dc065a 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -157,7 +157,6 @@ private:
Map<UGCall, Vector<Variant> > unique_group_calls;
bool ugc_locked;
void _flush_ugc();
- void _flush_transform_notifications();
_FORCE_INLINE_ void _update_group_order(Group &g);
void _update_listener();
@@ -344,6 +343,8 @@ public:
void notify_group(const StringName &p_group, int p_notification);
void set_group(const StringName &p_group, const String &p_name, const Variant &p_value);
+ void flush_transform_notifications();
+
virtual void input_text(const String &p_text);
virtual void input_event(const Ref<InputEvent> &p_event);
virtual void init();