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

Fix Node3D children using top_level in different position in-editor versus runtime #84643

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions scene/3d/node_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ void Node3D::_notification(int p_what) {

if (data.top_level && !Engine::get_singleton()->is_editor_hint()) {
if (data.parent) {
data.local_transform = data.parent->get_global_transform() * get_transform();
if (!data.top_level) {
data.local_transform = data.parent->get_global_transform() * get_transform();
} else {
data.local_transform = get_transform();
}
Comment on lines +152 to +156
Copy link
Member

Choose a reason for hiding this comment

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

Came across this while looking at the code and this check is always false, should the code not be just:

Suggested change
if (!data.top_level) {
data.local_transform = data.parent->get_global_transform() * get_transform();
} else {
data.local_transform = get_transform();
}
data.local_transform = get_transform();

Which I'm not sure is even necessary?

Copy link
Contributor

Choose a reason for hiding this comment

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

This was merged over a month ago, I'm not sure anyone's gonna see this comment?

Copy link
Member

@AThousandShips AThousandShips Mar 21, 2024

Choose a reason for hiding this comment

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

Op will and might give their thoughts? I might just make a PR for improving this code but communication is important :)

Also obviously someone did, and pretty fast...

Copy link
Contributor

Choose a reason for hiding this comment

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

I have a habit of browsing through Godot's notifications on GH :P

Copy link
Contributor

Choose a reason for hiding this comment

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

I got the notification. Why do you think it's always false?

Copy link
Member

@AThousandShips AThousandShips Mar 21, 2024

Choose a reason for hiding this comment

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

Well read two lines above :)

if (data.top_level && !Engine...)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah... Yeah haha.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for clearing this up

_replace_dirty_mask(DIRTY_EULER_ROTATION_AND_SCALE); // As local transform was updated, rot/scale should be dirty.
}
}
Expand Down Expand Up @@ -738,7 +742,7 @@ void Node3D::set_as_top_level(bool p_enabled) {
if (data.top_level == p_enabled) {
return;
}
if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) {
if (is_inside_tree()) {
if (p_enabled) {
set_transform(get_global_transform());
} else if (data.parent) {
Expand Down
Loading