-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Add a warning for when the scene root node is transformed #81892
base: master
Are you sure you want to change the base?
Add a warning for when the scene root node is transformed #81892
Conversation
a9dd0ac
to
532fa0a
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.
Tested locally, running fine.
I always miss the presence of GUID or some other unique identification on which is the object that generated the warning, but in this case it seens to be pretty much on topic here.
Note that this may change if we do decide to print node configuration warnings in a running project (when debugging is enabled). This is something I've considered at some point, as it can help with difficult-to-diagnose runtime-only issues without requiring code duplication. See godotengine/godot-proposals#3004. |
532fa0a
to
a6efd0d
Compare
a6efd0d
to
aa9bd7a
Compare
I'm personally not a fan of this. I believe warnings should be reserved for when the configuration of a node results in behavior that in all circumstances is not correct (like a collision without a node that derives from it). I don't see anything objectively wrong with changing the transforms of a root node, as long as instantiations of it are handled correctly such as in the above-mentioned PR. |
aa9bd7a
to
13533ad
Compare
The warning isn't entirely correct. Most often only position is overriden, e.g. when dropping the scene into viewport. |
13533ad
to
12bdf93
Compare
12bdf93
to
9a123b0
Compare
9a123b0
to
4c4c08c
Compare
4c4c08c
to
da2ba4f
Compare
I would argue that if users want a scene to have inherent scale or rotation, they should instead scale or rotate the child nodes. This way this inherent scale or rotation will not be discarded if the user sets If a user sets a scene's scale to be (2, 2, 2), it's expected that the scene should get bigger by a factor of 2. If the original scene had a root node scale of (10, 10, 10), this would result in the scene getting smaller by a factor of 5. |
da2ba4f
to
d7fe2cf
Compare
d7fe2cf
to
38b4f82
Compare
Isn't this (at least partially) superseded by #80561? |
@KoBeWi They are separate things, but you are correct that there is a partial overlap. However, this PR covers the case of a user accidentally transforming their scene's root node. |
So I'm not sure about the warning itself, but the implementation is fine. Except the warning does not update when you transform the node; you have to save the scene or update warnings in other way. Is that expected behavior? |
if (Object::cast_to<Node2D>(p_node)) { | ||
// Note: Warn for Node2D but not all CanvasItems, don't warn for Control nodes. | ||
// Control nodes may have reasons to use a transformed root node like anchors. | ||
Node2D *node_2d = Object::cast_to<Node2D>(p_node); |
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.
You can move this variable outside the condition instead of casting twice.
This is a low priority PR, but I think it's a good idea.
This PR adds a configuration warning for when the root node has a transform. This is usually a mistake when saving a branch as a scene, or having the wrong node selected when doing transform operations. Instances of the scene will set their own transform, so it's best practice to not have the root be transformed.