Make ViewportTexture path be updated relative to its local scene instead of the Viewport owner.

This commit is contained in:
Grandro 2024-10-05 23:17:49 +02:00
parent db66bd35af
commit 9a5b16a1f2

View file

@ -489,19 +489,16 @@ int Viewport::_sub_window_find(Window *p_window) const {
}
void Viewport::_update_viewport_path() {
if (viewport_textures.is_empty()) {
if (!is_inside_tree()) {
return;
}
Node *scene_root = get_scene_file_path().is_empty() ? get_owner() : this;
if (!scene_root && is_inside_tree()) {
scene_root = get_tree()->get_edited_scene_root();
}
if (scene_root && (scene_root == this || scene_root->is_ancestor_of(this))) {
NodePath path_in_scene = scene_root->get_path_to(this);
for (ViewportTexture *E : viewport_textures) {
E->path = path_in_scene;
for (ViewportTexture *E : viewport_textures) {
Node *loc_scene = E->get_local_scene();
if (!loc_scene) {
continue;
}
E->path = loc_scene->get_path_to(this);
}
}