diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2018-08-19 12:30:31 +0200 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2018-08-21 20:10:15 +0200 |
commit | 20dc63054f7846a9179b546dd3f02096ff4c6609 (patch) | |
tree | 8b31f9cce5b26bda389562cde3fd4dd9fb94f75c /scene/2d | |
parent | 4839e5f6d9ed1c0afee933009ab44b9913310d27 (diff) |
Optimize CanvasLayer::get_global_transform_with_canvas
So it takes advantage of the `get_global_transform` cached data.
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 { |