diff options
Diffstat (limited to 'scene/2d/canvas_item.cpp')
-rw-r--r-- | scene/2d/canvas_item.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 21615b7f55..17e5503a2d 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -455,20 +455,15 @@ void CanvasItem::_enter_canvas() { if ((!get_parent() || !get_parent()->cast_to<CanvasItem>()) || toplevel) { Node *n = this; - Viewport *viewport=NULL; + canvas_layer=NULL; while(n) { - if (n->cast_to<Viewport>()) { - - viewport = n->cast_to<Viewport>(); + canvas_layer = n->cast_to<CanvasLayer>(); + if (canvas_layer) { break; } - if (!canvas_layer && n->cast_to<CanvasLayer>()) { - - canvas_layer = n->cast_to<CanvasLayer>(); - } n=n->get_parent(); } @@ -476,7 +471,7 @@ void CanvasItem::_enter_canvas() { if (canvas_layer) canvas=canvas_layer->get_world_2d()->get_canvas(); else - canvas=viewport->find_world_2d()->get_canvas(); + canvas=get_viewport()->find_world_2d()->get_canvas(); VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,canvas); @@ -488,6 +483,7 @@ void CanvasItem::_enter_canvas() { } else { CanvasItem *parent = get_parent_item(); + canvas_layer=parent->canvas_layer; VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent->get_canvas_item()); parent->_queue_sort_children(); } @@ -1176,12 +1172,10 @@ Matrix32 CanvasItem::get_viewport_transform() const { return canvas_layer->get_transform(); } - } else if (get_viewport()) { + } else { return get_viewport()->get_final_transform() * get_viewport()->get_canvas_transform(); } - return Matrix32(); - } |