Make Control.global_position
represent the same point as position
, not global_transform.origin
#101719
+26
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note that the issues/discrepancies occur only for Controls with non-default
rotation
/scale
andpivot_offset
.After rethinking #95798 (comment) (please read for a detailed explanation of the issue), I think the current behavior is wrong.
Currently (after #89502)
Control.global_position
is being equivalent toControl.global_transform.origin
.However, AFAICT it makes more sense for
Control.global_position
to be instead representing the same exact point asControl.position
, just in a different coordinate system. AndControl.position
is not equivalent toControl.transform.origin
, because the transform incorporates rotation/scale around custom pivot, hence the final translation/origin part of such transform is not only theposition
. These imply thatControl.global_position
would be not equivalent toControl.global_transform.origin
:If:
Control.global_position
andControl.position
represent the same point.Control.global_transform.origin
andControl.transform.origin
represent the same point.Control.position
is not equivalent toControl.transform.origin
.then:
Control.global_position
is not equivalent toControl.global_transform.origin
.So this PR implements the alternative mentioned in #95798 (comment), now both
Control.global_position
andControl.position
represent the same point (but in different spaces (global/parent)). Also, as a consequence,Control.global_position
is no longer equivalent toControl.global_transform.origin
.Regarding compatibility breaking:
Control.set_global_position
andControl.get_global_position
was mixed/broken.Control::set_global_position
for rotated/scaled transforms #89502, makingControl.{set|get}_global_position
consistently referring toControl.global_transform.origin
(aka the same point asControl.transform.origin
(but in different coordinate system), which is not necessarily the same point asControl.position
).Control.global_position
andControl.position
representing different points. So I suggest merging for 4.4, whether it should / should not be cherry-picked for 4.3.1 I'm not sure.Fixes #95798.
Fixes #101692.
To-do (hence a draft):