From 75eacba5cd2fbbfc318e4c510d501e2283fdd20b Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Wed, 17 Apr 2024 09:55:40 +0800 Subject: Add Camera3D preview in Inspector --- editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp') diff --git a/editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp index 19dd45a3ea..afbf781683 100644 --- a/editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp @@ -46,24 +46,6 @@ Camera3DGizmoPlugin::Camera3DGizmoPlugin() { create_handle_material("handles"); } -Size2i Camera3DGizmoPlugin::_get_viewport_size(Camera3D *p_camera) { - Viewport *viewport = p_camera->get_viewport(); - - Window *window = Object::cast_to(viewport); - if (window) { - return window->get_size(); - } - - SubViewport *sub_viewport = Object::cast_to(viewport); - ERR_FAIL_NULL_V(sub_viewport, Size2i()); - - if (sub_viewport == EditorNode::get_singleton()->get_scene_root()) { - return Size2(GLOBAL_GET("display/window/size/viewport_width"), GLOBAL_GET("display/window/size/viewport_height")); - } - - return sub_viewport->get_size(); -} - bool Camera3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { return Object::cast_to(p_spatial) != nullptr; } @@ -163,7 +145,7 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Ref material = get_material("camera_material", p_gizmo); Ref icon = get_material("camera_icon", p_gizmo); - const Size2i viewport_size = _get_viewport_size(camera); + const Size2i viewport_size = Node3DEditor::get_camera_viewport_size(camera); const real_t viewport_aspect = viewport_size.x > 0 && viewport_size.y > 0 ? viewport_size.aspect() : 1.0; const Size2 size_factor = viewport_aspect > 1.0 ? Size2(1.0, 1.0 / viewport_aspect) : Size2(viewport_aspect, 1.0); -- cgit v1.2.3