Add a function to force transform update, fixes #17628
This commit is contained in:
parent
072bf41c03
commit
74359a1d1e
4 changed files with 29 additions and 0 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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); };
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -202,6 +202,8 @@ public:
|
|||
void hide();
|
||||
bool is_visible_in_tree() const;
|
||||
|
||||
void force_update_transform();
|
||||
|
||||
Spatial();
|
||||
~Spatial();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue