diff options
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/canvas_item.cpp | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index a035d9021f..7f7e3542ed 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -349,23 +349,12 @@ void CanvasItem::_update_callback() { Transform2D CanvasItem::get_global_transform_with_canvas() const { - const CanvasItem *ci = this; - Transform2D xform; - const CanvasItem *last_valid = NULL; - - while (ci) { - - last_valid = ci; - xform = ci->get_transform() * xform; - ci = ci->get_parent_item(); - } - - if (last_valid->canvas_layer) - return last_valid->canvas_layer->get_transform() * xform; + if (canvas_layer) + return canvas_layer->get_transform() * get_global_transform(); else if (is_inside_tree()) - return get_viewport()->get_canvas_transform() * xform; - - return xform; + return get_viewport()->get_canvas_transform() * get_global_transform(); + else + return get_global_transform(); } Transform2D CanvasItem::get_global_transform() const { |