Merge pull request #84643 from rsburke4/top-level-problem-fix

Fix `Node3D` children using `top_level` in different position in-editor versus runtime
This commit is contained in:
Rémi Verschelde 2024-02-02 12:01:25 +01:00
commit 7de27ea56a
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -148,7 +148,11 @@ void Node3D::_notification(int p_what) {
if (data.top_level && !Engine::get_singleton()->is_editor_hint()) {
if (data.parent) {
if (!data.top_level) {
data.local_transform = data.parent->get_global_transform() * get_transform();
} else {
data.local_transform = get_transform();
}
_replace_dirty_mask(DIRTY_EULER_ROTATION_AND_SCALE); // As local transform was updated, rot/scale should be dirty.
}
}
@ -737,7 +741,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) {