diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-09-06 20:38:16 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2018-09-06 20:38:16 -0300 |
commit | 74359a1d1e288a156d89e052d6b4ae6e8c187c6b (patch) | |
tree | 595419274d3a4040e60b4fba62a70c0afc2a7cb8 /scene | |
parent | 072bf41c037ef4c7aab23f1afa769c65c9dfdf73 (diff) |
Add a function to force transform update, fixes #17628
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/canvas_item.cpp | 13 | ||||
-rw-r--r-- | scene/2d/canvas_item.h | 2 | ||||
-rw-r--r-- | scene/3d/spatial.cpp | 12 | ||||
-rw-r--r-- | scene/3d/spatial.h | 2 |
4 files changed, 29 insertions, 0 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 7f7e3542ed..3914c75ca8 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -967,6 +967,17 @@ Vector2 CanvasItem::get_local_mouse_position() const { return get_global_transform().affine_inverse().xform(get_global_mouse_position()); } +void CanvasItem::force_update_transform() { + ERR_FAIL_COND(!is_inside_tree()); + if (!xform_change.in_list()) { + return; + } + + get_tree()->xform_change_list.remove(&xform_change); + + notification(NOTIFICATION_TRANSFORM_CHANGED); +} + void CanvasItem::_bind_methods() { ClassDB::bind_method(D_METHOD("_toplevel_raise_self"), &CanvasItem::_toplevel_raise_self); @@ -1061,6 +1072,8 @@ void CanvasItem::_bind_methods() { ClassDB::bind_method(D_METHOD("set_notify_transform", "enable"), &CanvasItem::set_notify_transform); ClassDB::bind_method(D_METHOD("is_transform_notification_enabled"), &CanvasItem::is_transform_notification_enabled); + ClassDB::bind_method(D_METHOD("force_update_transform"), &CanvasItem::force_update_transform); + ClassDB::bind_method(D_METHOD("make_canvas_position_local", "screen_point"), &CanvasItem::make_canvas_position_local); ClassDB::bind_method(D_METHOD("make_input_local", "event"), &CanvasItem::make_input_local); diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 1e6a251c9c..6dc2e2e39d 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -346,6 +346,8 @@ public: void set_notify_transform(bool p_enable); bool is_transform_notification_enabled() const; + void force_update_transform(); + // Used by control nodes to retreive the parent's anchorable area virtual Rect2 get_anchorable_rect() const { return Rect2(0, 0, 0, 0); }; diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index d52f634639..d6141c12a8 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -721,6 +721,16 @@ bool Spatial::is_local_transform_notification_enabled() const { return data.notify_local_transform; } +void Spatial::force_update_transform() { + ERR_FAIL_COND(!is_inside_tree()); + if (!xform_change.in_list()) { + return; //nothing to update + } + get_tree()->xform_change_list.remove(&xform_change); + + notification(NOTIFICATION_TRANSFORM_CHANGED); +} + void Spatial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_transform", "local"), &Spatial::set_transform); @@ -743,6 +753,8 @@ void Spatial::_bind_methods() { ClassDB::bind_method(D_METHOD("is_scale_disabled"), &Spatial::is_scale_disabled); ClassDB::bind_method(D_METHOD("get_world"), &Spatial::get_world); + ClassDB::bind_method(D_METHOD("force_update_transform"), &Spatial::force_update_transform); + ClassDB::bind_method(D_METHOD("_update_gizmo"), &Spatial::_update_gizmo); ClassDB::bind_method(D_METHOD("update_gizmo"), &Spatial::update_gizmo); diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h index 8d3c32d116..815ca16bc5 100644 --- a/scene/3d/spatial.h +++ b/scene/3d/spatial.h @@ -202,6 +202,8 @@ public: void hide(); bool is_visible_in_tree() const; + void force_update_transform(); + Spatial(); ~Spatial(); }; |