diff options
author | kobewi <kobewi4e@gmail.com> | 2023-03-30 22:37:00 +0200 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-04-26 14:32:20 +0200 |
commit | 82aab2b0ea1fa4d5931892274a99e91235ba842b (patch) | |
tree | 2f5e1064e47d0c52062f131c8aa8a182db433d77 /scene/main/canvas_item.cpp | |
parent | c8ed59ba41637c1ab119463c64ca00477b257a5b (diff) |
Fix invalid global position when read outside tree
(cherry picked from commit 727a4ed79a371d87be06a8101c9eedd48ecc3e01)
Diffstat (limited to 'scene/main/canvas_item.cpp')
-rw-r--r-- | scene/main/canvas_item.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index de76d3610d..c8015649b5 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -142,6 +142,10 @@ void CanvasItem::_redraw_callback() { pending_update = false; // don't change to false until finished drawing (avoid recursive update) } +void CanvasItem::_invalidate_global_transform() { + global_invalid = true; +} + Transform2D CanvasItem::get_global_transform_with_canvas() const { if (canvas_layer) { return canvas_layer->get_final_transform() * get_global_transform(); @@ -289,6 +293,7 @@ void CanvasItem::_notification(int p_what) { } } + global_invalid = true; _enter_canvas(); RenderingServer::get_singleton()->canvas_item_set_visible(canvas_item, is_visible_in_tree()); // The visibility of the parent may change. @@ -394,6 +399,7 @@ void CanvasItem::set_as_top_level(bool p_top_level) { if (!is_inside_tree()) { top_level = p_top_level; + propagate_call(SNAME("_invalidate_global_transform")); return; } @@ -941,6 +947,7 @@ void CanvasItem::_validate_property(PropertyInfo &p_property) const { void CanvasItem::_bind_methods() { ClassDB::bind_method(D_METHOD("_top_level_raise_self"), &CanvasItem::_top_level_raise_self); + ClassDB::bind_method(D_METHOD("_invalidate_global_transform"), &CanvasItem::_invalidate_global_transform); #ifdef TOOLS_ENABLED ClassDB::bind_method(D_METHOD("_edit_set_state", "state"), &CanvasItem::_edit_set_state); |