summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scene/main/viewport.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 5e8868c326..9297d49e2b 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -331,21 +331,25 @@ void Viewport::_notification(int p_what) {
}
}
- if (!render_target)
- _vp_enter_tree();
- this->parent=NULL;
- Node *parent=get_parent();
+ parent=NULL;
+ Node *parent_node=get_parent();
- if (parent) {
+ while(parent_node) {
- while(parent && !(this->parent=parent->cast_to<Viewport>())) {
+ parent = parent_node->cast_to<Viewport>();
+ if (parent)
+ break;
- parent=parent->get_parent();
- }
+ parent_node=parent_node->get_parent();
}
+
+ if (!render_target)
+ _vp_enter_tree();
+
+
current_canvas=find_world_2d()->get_canvas();
VisualServer::get_singleton()->viewport_set_scenario(viewport,find_world()->get_scenario());
VisualServer::get_singleton()->viewport_attach_canvas(viewport,current_canvas);