Skip to content
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

Remove error condition from get_global_transform() #67710

Merged
merged 1 commit into from
Oct 31, 2022

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Oct 21, 2022

Removes the arbitrary error in get_global_transform() method.

The error makes no sense for a couple of reasons:

  • it only triggers in debug build, which means the method works differently in release build
  • even with the error, the transform may not be truly "global", because Node ancestors stop transform propagation
    • if node is not inside tree, it has null parent, which is effectively the same as having Node parent

Closes #30445

@KoBeWi KoBeWi added enhancement cherrypick:3.x Considered for cherry-picking into a future 3.x release topic:2d labels Oct 21, 2022
@KoBeWi KoBeWi added this to the 4.0 milestone Oct 21, 2022
@KoBeWi KoBeWi requested review from a team as code owners October 21, 2022 12:58
@KoBeWi KoBeWi modified the milestones: 4.0, 4.x Oct 21, 2022
@Sauermann
Copy link
Contributor

Sauermann commented Oct 21, 2022

This change makes sense to me. Don't see any problems with the implementation.

Copy link
Member

@aaronfranke aaronfranke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me.

@mhilbrunner
Copy link
Member

@reduz originally added this in 83ae9a5, thoughts?

@Sauermann
Copy link
Contributor

Sauermann commented Oct 21, 2022

@mhilbrunner
In 83ae9a5 CanvasItem::set_notify_transform is changed and adds a call to get_global_transform, but verifies beforehand, that the node is in the tree.
So this PR does not change anything for CanvasItem::set_notify_transform, as far as I can tell.

@akien-mga akien-mga modified the milestones: 4.x, 4.0 Oct 31, 2022
@akien-mga akien-mga merged commit 71a6aba into godotengine:master Oct 31, 2022
@akien-mga
Copy link
Member

Thanks!

@KoBeWi KoBeWi deleted the a_bit_local_global_transform branch October 31, 2022 11:45
@timothyqiu
Copy link
Member

Cherry-picked for 3.6.

@timothyqiu timothyqiu removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Dec 1, 2022
@lawnjelly
Copy link
Member

lawnjelly commented Dec 1, 2022

Just seen this has been cherry picked! Yay, had been waiting for this for a while (see #30445 ) .

Ah, I've just seen, this PR is for canvas item, and the issue is for Spatial.

Also a possible bug - I haven't checked whether this occurs yet. If you remove a branch from the scene tree then unless the global transform is made dirty then the results will be stale (i.e. still represent the transform within the tree). So when removing from the tree we would need to propagate dirty flags to ensure consistent result. I'm not sure if this is done already, will check.

EDIT: The global_invalid is set when exiting the tree, so it should be consistent and there is no bug there currently. 👍
This should be checked though if we decide to do same for 3D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accessing global_transform from a node which is not in the tree causes errors
7 participants