summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Sizov <yuris@humnom.net>2023-05-18 21:41:34 +0200
committerYuri Sizov <yuris@humnom.net>2023-05-18 21:46:40 +0200
commiteced93a3f57765a7c82b522314511c5e93c48971 (patch)
tree73f27b56af342907ccf267b798cb7b94af848586
parent589306a9d81c8d63c86269c53990c52fb6d1b503 (diff)
Revert "Improve the UX of ViewportTexture in the editor"
This reverts commit b91b8fce43ab9cb9f8c96f8c640acc801774b6b5.
-rw-r--r--doc/classes/ViewportTexture.xml1
-rw-r--r--editor/editor_properties.cpp1
-rw-r--r--scene/main/viewport.cpp46
-rw-r--r--scene/main/viewport.h2
4 files changed, 4 insertions, 46 deletions
diff --git a/doc/classes/ViewportTexture.xml b/doc/classes/ViewportTexture.xml
index 36390863cf..8ecda45bd6 100644
--- a/doc/classes/ViewportTexture.xml
+++ b/doc/classes/ViewportTexture.xml
@@ -17,7 +17,6 @@
<members>
<member name="viewport_path" type="NodePath" setter="set_viewport_path_in_scene" getter="get_viewport_path_in_scene" default="NodePath(&quot;&quot;)">
The path to the [Viewport] node to display. This is relative to the scene root, not to the node which uses the texture.
- [b]Note:[/b] In the editor, it is automatically updated when the target viewport's node path changes due to renaming or moving the viewport or its ancestors. At runtime, it may not be able to automatically update due to the inability to determine the scene root.
</member>
</members>
</class>
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 348e1ead4a..01a574def6 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -3998,6 +3998,7 @@ void EditorPropertyResource::_viewport_selected(const NodePath &p_path) {
Ref<ViewportTexture> vt;
vt.instantiate();
vt->set_viewport_path_in_scene(get_tree()->get_edited_scene_root()->get_path_to(to_node));
+ vt->setup_local_to_scene();
emit_changed(get_edited_property(), vt);
update_property();
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 4aaa2e8f5b..8bdcd9302f 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -72,9 +72,10 @@ void ViewportTexture::setup_local_to_scene() {
if (vp) {
vp->viewport_textures.erase(this);
- vp = nullptr;
}
+ vp = nullptr;
+
if (loc_scene->is_ready()) {
_setup_local_to_scene(loc_scene);
} else {
@@ -90,24 +91,8 @@ void ViewportTexture::set_viewport_path_in_scene(const NodePath &p_path) {
path = p_path;
- if (vp) {
- vp->viewport_textures.erase(this);
- vp = nullptr;
- }
-
- if (proxy_ph.is_valid()) {
- RS::get_singleton()->free(proxy_ph);
- }
- if (proxy.is_valid()) {
- RS::get_singleton()->free(proxy);
- }
- proxy_ph = RID();
- proxy = RID();
-
- if (get_local_scene() && !path.is_empty()) {
+ if (get_local_scene()) {
setup_local_to_scene();
- } else {
- emit_changed();
}
}
@@ -186,8 +171,6 @@ void ViewportTexture::_setup_local_to_scene(const Node *p_loc_scene) {
proxy = RS::get_singleton()->texture_proxy_create(vp->texture_rid);
}
vp_pending = false;
-
- emit_changed();
}
void ViewportTexture::_bind_methods() {
@@ -425,28 +408,9 @@ int Viewport::_sub_window_find(Window *p_window) {
return -1;
}
-void Viewport::_update_viewport_path() {
- if (viewport_textures.is_empty()) {
- 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;
- }
- }
-}
-
void Viewport::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- _update_viewport_path();
-
if (get_parent()) {
parent = get_parent()->get_viewport();
RenderingServer::get_singleton()->viewport_set_parent_viewport(viewport, parent->get_viewport_rid());
@@ -539,10 +503,6 @@ void Viewport::_notification(int p_what) {
RenderingServer::get_singleton()->viewport_set_parent_viewport(viewport, RID());
} break;
- case NOTIFICATION_PATH_RENAMED: {
- _update_viewport_path();
- } break;
-
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (!get_tree()) {
return;
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index de0abec052..e88e0628dd 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -317,8 +317,6 @@ private:
Ref<ViewportTexture> default_texture;
HashSet<ViewportTexture *> viewport_textures;
- void _update_viewport_path();
-
SDFOversize sdf_oversize = SDF_OVERSIZE_120_PERCENT;
SDFScale sdf_scale = SDF_SCALE_50_PERCENT;