-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent behavior when rotating control nodes #95798
Comments
Can't fully confirm but might be related to:
Could be a consequence of either fix, unsure if 4.2.2 or 4.3 behavior is intended (i.e. if this is a bug, or if you were relying on bugged behavior in 4.2.2 that was fixed) |
Probably because Lines 1552 to 1566 in da5f398
It might be better to provide a dedicated |
In 4.2.2 (and earlier) there is a discrepancy between what global position "means" in context of
For a
Because of the above, doing
The above discrepancy / buggy behavior was ultimately fixed in 4.3, by #89502 (#87432 was incorrect and caused #89497). It made both Hence this is expected that MRP which is conceptually doing After changing extends Control
@onready var rotating: TextureButton = $Rotating
var is_dragging = false
func _process(delta: float) -> void:
if Input.is_action_just_pressed("click"):
is_dragging = !is_dragging
if Input.is_action_just_pressed("right_click"):
rotating.rotate()
if is_dragging:
# (1)
#var half_size: Vector2 = rotating.size / 2
#rotating.global_position = get_global_mouse_position() - half_size
# (2)
#var half_size_global: Vector2 = rotating.get_global_transform().basis_xform(rotating.size / 2)
#rotating.global_position = get_global_mouse_position() - half_size_global
# (3)
#var half_size_parent_global: Vector2 = (rotating.get_global_transform() * rotating.get_transform().affine_inverse()).basis_xform(rotating.size / 2)
#rotating.global_position = get_global_mouse_position() - half_size_parent_global
%RectLabel.text = "Rect: %s" % str(rotating.get_global_rect()) Here's a visualization of the behavior after uncommenting section (1) or (2):
But note that even though the code from (1) seemingly works in 4.2.2, it's not guaranteed to always work. For simple case sure it does. But in general to properly obtain the unrotated/unscaled position something like (3) would need to be done instead. Here's for example what happens after rotating and scaling the parent
Thus it's not like doing things properly was simpler in 4.2.2. To sum up, in 4.3 the behavior of However, note that it could have been potentially fixed the other way around. Instead of changing If
If
In the end we can't make everything consistent with Node2D/Node3D because of how for Control there's an additional pivot "between" its parent and local coordinate spaces. Regardless of whether we will leave the behavior as in v4.3.stable.official [77dcf97], or change it to the alternative (after concluding it's better for some reason), we could of course potentially consider adding some helper methods/properties to Control (or just documenting better? 🤔). So suggestions/proposals about what could be improved are of course welcomed (implementation shouldn't be a problem). 🙂 |
When the pivot is not at the default position (top left corner, i.e. This may be more mathematical, but the values may not be very intuitive. |
relevant in version v4.4.dev2.official [97ef3c8]. |
Tested versions
Reproduciable in 4.3 stable, not reproduciable in 4.2.2 stable
System information
Windows 10
Issue description
Rotating a control node doesn't rotate on the pivot offset as expected if you change the node's position while rotating
Steps to reproduce
Minimal reproduction project (MRP)
RotationTest.zip
The text was updated successfully, but these errors were encountered: