-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Fix cannot update remote after disabling use_global_coordinates
in RemoteTransform2D
#83323
Fix cannot update remote after disabling use_global_coordinates
in RemoteTransform2D
#83323
Conversation
Provide a scene for testing. |
That's not really true as both Node2D and Control do call So AFAICT for RemoteTransform2D the Given all this, this PR still makes sense because when |
godot/scene/main/canvas_item.cpp Lines 890 to 892 in a574c02
godot/scene/main/canvas_item.cpp Line 181 in a574c02
This flag doesn't seem to change in |
I wrongly assumed that But because it's called on godot/scene/main/canvas_item.cpp Lines 371 to 376 in a574c02
and because NOTIFICATION_PARENTED is received before a node is added to the tree, then it results in is_inside_tree() check to fail:godot/scene/main/canvas_item.cpp Lines 896 to 907 in a574c02
Hence after such CanvasItem is added to the SceneTree it's marked as having invalid global but it's not added to the SceneTree::xform_change_list which would result in propagating NOTIFICATION_TRANSFORM_CHANGED :godot/scene/main/scene_tree.cpp Lines 179 to 190 in a574c02
Seems like potentially a bigger issue? 🤔 Regarding specifically the changes in this PR the 2D part looks good to me anyway. I haven't dived into 3D notifications. |
There is currently no relevant optimization in 3D. If it is not needed, I can reset that commit.
Edit: |
Indeed, so what I've said in #83323 (comment) is true for the RemoteTransform3D (but not for the RemoteTransform2D because of the discussed optimization). Meaning only 2D was bugged.
No, the changes are good. 👍 Quoting myself (just replace RemoteTransform2D with RemoteTransform3D):
|
dce55f4
to
66f063b
Compare
…`RemoteTransform2D` Due to the optimization in `CanvasItem`, `global_transform` is only updated when `get_global_transform()` is called, and then notify `NOTIFICATION_TRANSFORM_CHANGED`. That is, in the case where `global_transform` is not obtained, the notification will not be sent. So we use `NOTIFICATION_LOCAL_TRANSFORM_CHANGED` in this case. Use in combination to prevent certain optimizations. Same change for `RemoteTransform3D`, to prevent the same optimization from being used in `Node3D` in the future.
66f063b
to
30904ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
I've also tested it is some more (debug-stepped through some notification code etc.), haven't noticed any issue.
Changed milestone to 4.2 as 2D part is a bugfix (3D part can be treated as an enhancement as it effectively only removes some redundant transform updates for the target node).
Thanks! |
Due to the optimization in
CanvasItem
,global_transform
is only updated whenget_global_transform()
is called, and then notifyNOTIFICATION_TRANSFORM_CHANGED
. That is, in the case whereglobal_transform
is not obtained, the notificationNOTIFICATION_TRANSFORM_CHANGED
will not be sent.So we use
NOTIFICATION_LOCAL_TRANSFORM_CHANGED
in this case. Use in combination to prevent certain optimizations.Fix #83297 (comment).
Same change for
RemoteTransform3D
, to prevent the same optimization from being used in Node3D in the future.