diff --git a/doc/classes/SubViewportContainer.xml b/doc/classes/SubViewportContainer.xml
new file mode 100644
index 00000000000..e6a0bd48667
--- /dev/null
+++ b/doc/classes/SubViewportContainer.xml
@@ -0,0 +1,25 @@
+
+
+
+ Control for holding [SubViewport]s.
+
+
+ A [Container] node that holds a [SubViewport], automatically setting its size.
+
+
+
+
+
+
+
+ If [code]true[/code], the sub-viewport will be scaled to the control's size.
+
+
+ Divides the sub-viewport's effective resolution by this value while preserving its scale. This can be used to speed up rendering.
+ For example, a 1280×720 sub-viewport with [member stretch_shrink] set to [code]2[/code] will be rendered at 640×360 while occupying the same size in the container.
+ [b]Note:[/b] [member stretch] must be [code]true[/code] for this property to work.
+
+
+
+
+
diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml
index 517eb3b24ce..5826822c6e5 100644
--- a/doc/classes/Viewport.xml
+++ b/doc/classes/Viewport.xml
@@ -6,7 +6,7 @@
A Viewport creates a different view into the screen, or a sub-view inside another viewport. Children 2D Nodes will display on it, and children Camera3D 3D nodes will render on it too.
Optionally, a viewport can have its own 2D or 3D world, so they don't share what they draw with other viewports.
- If a viewport is a child of a [ViewportContainer], it will automatically take up its size, otherwise it must be set manually.
+ If a viewport is a child of a [SubViewportContainer], it will automatically take up its size, otherwise it must be set manually.
Viewports can also choose to be audio listeners, so they generate positional audio depending on a 2D or 3D camera child of it.
Also, viewports can be assigned to different screens in case the devices have multiple screens.
Finally, viewports can also behave as render targets, in which case they will not be visible unless the associated texture is used to draw.
diff --git a/doc/classes/ViewportContainer.xml b/doc/classes/ViewportContainer.xml
deleted file mode 100644
index d2fbb853051..00000000000
--- a/doc/classes/ViewportContainer.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
- Control for holding [Viewport]s.
-
-
- A [Container] node that holds a [Viewport], automatically setting its size.
-
-
-
-
-
-
-
- If [code]true[/code], the viewport will be scaled to the control's size.
-
-
- Divides the viewport's effective resolution by this value while preserving its scale. This can be used to speed up rendering.
- For example, a 1280×720 viewport with [member stretch_shrink] set to [code]2[/code] will be rendered at 640×360 while occupying the same size in the container.
- [b]Note:[/b] [member stretch] must be [code]true[/code] for this property to work.
-
-
-
-
-
diff --git a/editor/icons/ViewportContainer.svg b/editor/icons/SubViewportContainer.svg
similarity index 100%
rename from editor/icons/ViewportContainer.svg
rename to editor/icons/SubViewportContainer.svg
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index d8b9fb4d8fb..2f7747d0ff9 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -48,7 +48,7 @@
#include "scene/2d/touch_screen_button.h"
#include "scene/gui/grid_container.h"
#include "scene/gui/nine_patch_rect.h"
-#include "scene/gui/viewport_container.h"
+#include "scene/gui/subviewport_container.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
@@ -5434,7 +5434,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
viewport_scrollable->set_h_size_flags(Control::SIZE_EXPAND_FILL);
viewport_scrollable->connect("draw", callable_mp(this, &CanvasItemEditor::_update_scrollbars));
- ViewportContainer *scene_tree = memnew(ViewportContainer);
+ SubViewportContainer *scene_tree = memnew(SubViewportContainer);
viewport_scrollable->add_child(scene_tree);
scene_tree->set_stretch(true);
scene_tree->set_anchors_and_margins_preset(Control::PRESET_WIDE);
diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index 56238052017..00e8a05e4e6 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -31,7 +31,7 @@
#include "material_editor_plugin.h"
#include "editor/editor_scale.h"
-#include "scene/gui/viewport_container.h"
+#include "scene/gui/subviewport_container.h"
#include "scene/resources/particles_material.h"
#include "scene/resources/sky_material.h"
@@ -110,7 +110,7 @@ void MaterialEditor::_bind_methods() {
MaterialEditor::MaterialEditor() {
- vc = memnew(ViewportContainer);
+ vc = memnew(SubViewportContainer);
vc->set_stretch(true);
add_child(vc);
vc->set_anchors_and_margins_preset(PRESET_WIDE);
diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h
index 0938e79ca24..50036e4f726 100644
--- a/editor/plugins/material_editor_plugin.h
+++ b/editor/plugins/material_editor_plugin.h
@@ -41,13 +41,13 @@
#include "scene/3d/mesh_instance_3d.h"
#include "scene/resources/material.h"
-class ViewportContainer;
+class SubViewportContainer;
class MaterialEditor : public Control {
GDCLASS(MaterialEditor, Control);
- ViewportContainer *vc;
+ SubViewportContainer *vc;
SubViewport *viewport;
MeshInstance3D *sphere_instance;
MeshInstance3D *box_instance;
diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h
index 59810517d9e..072e21f260e 100644
--- a/editor/plugins/mesh_editor_plugin.h
+++ b/editor/plugins/mesh_editor_plugin.h
@@ -36,12 +36,12 @@
#include "scene/3d/camera_3d.h"
#include "scene/3d/light_3d.h"
#include "scene/3d/mesh_instance_3d.h"
-#include "scene/gui/viewport_container.h"
+#include "scene/gui/subviewport_container.h"
#include "scene/resources/material.h"
-class MeshEditor : public ViewportContainer {
+class MeshEditor : public SubViewportContainer {
- GDCLASS(MeshEditor, ViewportContainer);
+ GDCLASS(MeshEditor, SubViewportContainer);
float rot_x;
float rot_y;
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index afd8d2d0752..2a273320515 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -48,7 +48,7 @@
#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/physics_body_3d.h"
#include "scene/3d/visual_instance_3d.h"
-#include "scene/gui/viewport_container.h"
+#include "scene/gui/subviewport_container.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/surface_tool.h"
#include "servers/display_server.h"
@@ -418,12 +418,12 @@ Vector3 Node3DEditorViewport::_get_camera_position() const {
Point2 Node3DEditorViewport::_point_to_screen(const Vector3 &p_point) {
- return camera->unproject_position(p_point) * viewport_container->get_stretch_shrink();
+ return camera->unproject_position(p_point) * subviewport_container->get_stretch_shrink();
}
Vector3 Node3DEditorViewport::_get_ray_pos(const Vector2 &p_pos) const {
- return camera->project_ray_origin(p_pos / viewport_container->get_stretch_shrink());
+ return camera->project_ray_origin(p_pos / subviewport_container->get_stretch_shrink());
}
Vector3 Node3DEditorViewport::_get_camera_normal() const {
@@ -433,7 +433,7 @@ Vector3 Node3DEditorViewport::_get_camera_normal() const {
Vector3 Node3DEditorViewport::_get_ray(const Vector2 &p_pos) const {
- return camera->project_ray_normal(p_pos / viewport_container->get_stretch_shrink());
+ return camera->project_ray_normal(p_pos / subviewport_container->get_stretch_shrink());
}
void Node3DEditorViewport::_clear_selected() {
@@ -494,7 +494,7 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b
Vector3 ray = _get_ray(p_pos);
Vector3 pos = _get_ray_pos(p_pos);
- Vector2 shrinked_pos = p_pos / viewport_container->get_stretch_shrink();
+ Vector2 shrinked_pos = p_pos / subviewport_container->get_stretch_shrink();
Vector instances = RenderingServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario());
Set[> found_gizmos;
@@ -2472,8 +2472,8 @@ void Node3DEditorViewport::_notification(int p_what) {
bool shrink = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION));
- if (shrink != (viewport_container->get_stretch_shrink() > 1)) {
- viewport_container->set_stretch_shrink(shrink ? 2 : 1);
+ if (shrink != (subviewport_container->get_stretch_shrink() > 1)) {
+ subviewport_container->set_stretch_shrink(shrink ? 2 : 1);
}
//update msaa if changed
@@ -3237,8 +3237,8 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
const int viewport_base_height = 400 * MAX(1, EDSCALE);
gizmo_scale =
(gizmo_size / Math::abs(dd)) * MAX(1, EDSCALE) *
- MIN(viewport_base_height, viewport_container->get_size().height) / viewport_base_height /
- viewport_container->get_stretch_shrink();
+ MIN(viewport_base_height, subviewport_container->get_size().height) / viewport_base_height /
+ subviewport_container->get_stretch_shrink();
Vector3 scale = Vector3(1, 1, 1) * gizmo_scale;
xform.basis.scale(scale);
@@ -3398,7 +3398,7 @@ Dictionary Node3DEditorViewport::get_state() const {
d["gizmos"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_GIZMOS));
d["information"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION));
d["fps"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FPS));
- d["half_res"] = viewport_container->get_stretch_shrink() > 1;
+ d["half_res"] = subviewport_container->get_stretch_shrink() > 1;
d["cinematic_preview"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_CINEMATIC_PREVIEW));
if (previewing)
d["previewing"] = EditorNode::get_singleton()->get_edited_scene()->get_path_to(previewing);
@@ -3829,8 +3829,8 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
zoom_indicator_delay = 0.0;
spatial_editor = p_spatial_editor;
- ViewportContainer *c = memnew(ViewportContainer);
- viewport_container = c;
+ SubViewportContainer *c = memnew(SubViewportContainer);
+ subviewport_container = c;
c->set_stretch(true);
add_child(c);
c->set_anchors_and_margins_preset(Control::PRESET_WIDE);
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index e485edae02d..552afb99e0c 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -43,7 +43,7 @@ class Camera3D;
class Node3DEditor;
class EditorNode3DGizmoPlugin;
class Node3DEditorViewport;
-class ViewportContainer;
+class SubViewportContainer;
class EditorNode3DGizmo : public Node3DGizmo {
@@ -256,7 +256,7 @@ private:
UndoRedo *undo_redo;
CheckBox *preview_camera;
- ViewportContainer *viewport_container;
+ SubViewportContainer *subviewport_container;
MenuButton *view_menu;
PopupMenu *display_submenu;
diff --git a/scene/gui/viewport_container.cpp b/scene/gui/subviewport_container.cpp
similarity index 81%
rename from scene/gui/viewport_container.cpp
rename to scene/gui/subviewport_container.cpp
index 7ce1d9e551a..50f468741d4 100644
--- a/scene/gui/viewport_container.cpp
+++ b/scene/gui/subviewport_container.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* viewport_container.cpp */
+/* subviewport_container.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,12 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "viewport_container.h"
+#include "subviewport_container.h"
#include "core/engine.h"
#include "scene/main/viewport.h"
-Size2 ViewportContainer::get_minimum_size() const {
+Size2 SubViewportContainer::get_minimum_size() const {
if (stretch)
return Size2();
@@ -52,19 +52,19 @@ Size2 ViewportContainer::get_minimum_size() const {
return ms;
}
-void ViewportContainer::set_stretch(bool p_enable) {
+void SubViewportContainer::set_stretch(bool p_enable) {
stretch = p_enable;
queue_sort();
update();
}
-bool ViewportContainer::is_stretch_enabled() const {
+bool SubViewportContainer::is_stretch_enabled() const {
return stretch;
}
-void ViewportContainer::set_stretch_shrink(int p_shrink) {
+void SubViewportContainer::set_stretch_shrink(int p_shrink) {
ERR_FAIL_COND(p_shrink < 1);
if (shrink == p_shrink)
@@ -87,12 +87,12 @@ void ViewportContainer::set_stretch_shrink(int p_shrink) {
update();
}
-int ViewportContainer::get_stretch_shrink() const {
+int SubViewportContainer::get_stretch_shrink() const {
return shrink;
}
-void ViewportContainer::_notification(int p_what) {
+void SubViewportContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_RESIZED) {
@@ -142,7 +142,7 @@ void ViewportContainer::_notification(int p_what) {
}
}
-void ViewportContainer::_input(const Ref &p_event) {
+void SubViewportContainer::_input(const Ref &p_event) {
if (Engine::get_singleton()->is_editor_hint())
return;
@@ -167,7 +167,7 @@ void ViewportContainer::_input(const Ref &p_event) {
}
}
-void ViewportContainer::_unhandled_input(const Ref &p_event) {
+void SubViewportContainer::_unhandled_input(const Ref &p_event) {
if (Engine::get_singleton()->is_editor_hint())
return;
@@ -192,21 +192,21 @@ void ViewportContainer::_unhandled_input(const Ref &p_event) {
}
}
-void ViewportContainer::_bind_methods() {
+void SubViewportContainer::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_unhandled_input", "event"), &ViewportContainer::_unhandled_input);
- ClassDB::bind_method(D_METHOD("_input", "event"), &ViewportContainer::_input);
- ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &ViewportContainer::set_stretch);
- ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &ViewportContainer::is_stretch_enabled);
+ ClassDB::bind_method(D_METHOD("_unhandled_input", "event"), &SubViewportContainer::_unhandled_input);
+ ClassDB::bind_method(D_METHOD("_input", "event"), &SubViewportContainer::_input);
+ ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &SubViewportContainer::set_stretch);
+ ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &SubViewportContainer::is_stretch_enabled);
- ClassDB::bind_method(D_METHOD("set_stretch_shrink", "amount"), &ViewportContainer::set_stretch_shrink);
- ClassDB::bind_method(D_METHOD("get_stretch_shrink"), &ViewportContainer::get_stretch_shrink);
+ ClassDB::bind_method(D_METHOD("set_stretch_shrink", "amount"), &SubViewportContainer::set_stretch_shrink);
+ ClassDB::bind_method(D_METHOD("get_stretch_shrink"), &SubViewportContainer::get_stretch_shrink);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stretch"), "set_stretch", "is_stretch_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "stretch_shrink"), "set_stretch_shrink", "get_stretch_shrink");
}
-ViewportContainer::ViewportContainer() {
+SubViewportContainer::SubViewportContainer() {
stretch = false;
shrink = 1;
diff --git a/scene/gui/viewport_container.h b/scene/gui/subviewport_container.h
similarity index 93%
rename from scene/gui/viewport_container.h
rename to scene/gui/subviewport_container.h
index 85974444260..6ff3d188e21 100644
--- a/scene/gui/viewport_container.h
+++ b/scene/gui/subviewport_container.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* viewport_container.h */
+/* subviewport_container.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,9 +33,9 @@
#include "scene/gui/container.h"
-class ViewportContainer : public Container {
+class SubViewportContainer : public Container {
- GDCLASS(ViewportContainer, Container);
+ GDCLASS(SubViewportContainer, Container);
bool stretch;
int shrink;
@@ -55,7 +55,7 @@ public:
virtual Size2 get_minimum_size() const;
- ViewportContainer();
+ SubViewportContainer();
};
#endif // VIEWPORTCONTAINER_H
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index e11abb5fba4..94162cbe4e7 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -110,6 +110,7 @@
#include "scene/gui/slider.h"
#include "scene/gui/spin_box.h"
#include "scene/gui/split_container.h"
+#include "scene/gui/subviewport_container.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/tabs.h"
#include "scene/gui/text_edit.h"
@@ -119,7 +120,6 @@
#include "scene/gui/tool_button.h"
#include "scene/gui/tree.h"
#include "scene/gui/video_player.h"
-#include "scene/gui/viewport_container.h"
#include "scene/main/canvas_item.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/http_request.h"
@@ -357,7 +357,7 @@ void register_scene_types() {
ClassDB::register_class();
ClassDB::register_class();
- ClassDB::register_class();
+ ClassDB::register_class();
ClassDB::register_virtual_class();
ClassDB::register_class();
ClassDB::register_class();
@@ -842,6 +842,7 @@ void register_scene_types() {
ClassDB::add_compatibility_class("StaticBody", "StaticBody3D");
ClassDB::add_compatibility_class("VehicleBody", "VehicleBody3D");
ClassDB::add_compatibility_class("VehicleWheel", "VehicleWheel3D");
+ ClassDB::add_compatibility_class("ViewportContainer", "SubViewportContainer");
ClassDB::add_compatibility_class("VisibilityEnabler", "VisibilityEnabler3D");
ClassDB::add_compatibility_class("VisibilityNotifier", "VisibilityNotifier3D");
ClassDB::add_compatibility_class("VisualServer", "RenderingServer");
]