From 42c737bf9ee4417c729d710d2dba0a2fd5552fbd Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 21 Jun 2024 18:34:26 +0200 Subject: [PATCH] Use Viewport's 3D Scaling in the 3D editor's Half Resolution option This removes the reliance on Viewport shrinking, which fixes various bugs with mouse input handling in 3D gizmos or the GridMap editor. This also makes Half Resolution make use of the current 3D scaling mode defined in the project setting (bilinear, FSR1 or FSR2). When Half Resolution is checked, the Scaling 3D Scale value in the project settings is halved in the editor. To ensure the 3D view remaisn somewhat readable, the final value can't go below the minimum value allowed in the project settings, which is 0.25. --- editor/plugins/node_3d_editor_plugin.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index d7d51d6a044c..3947db6a6cd7 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -669,9 +669,9 @@ void Node3DEditorViewport::cancel_transform() { } void Node3DEditorViewport::_update_shrink() { - bool shrink = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION)); - subviewport_container->set_stretch_shrink(shrink ? 2 : 1); - subviewport_container->set_texture_filter(shrink ? TEXTURE_FILTER_NEAREST : TEXTURE_FILTER_PARENT_NODE); + const float scaling_3d_scale = GLOBAL_GET("rendering/scaling_3d/scale"); + const float shrink_factor = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION)) ? 0.5 : 1.0; + viewport->set_scaling_3d_scale(MAX(0.25, scaling_3d_scale * shrink_factor)); } float Node3DEditorViewport::get_znear() const { @@ -2729,8 +2729,6 @@ void Node3DEditorViewport::_project_settings_changed() { viewport->set_positional_shadow_atlas_quadrant_subdiv(2, Viewport::PositionalShadowAtlasQuadrantSubdiv(atlas_q2)); viewport->set_positional_shadow_atlas_quadrant_subdiv(3, Viewport::PositionalShadowAtlasQuadrantSubdiv(atlas_q3)); - _update_shrink(); - // Update MSAA, screen-space AA and debanding if changed const int msaa_mode = GLOBAL_GET("rendering/anti_aliasing/quality/msaa_3d"); @@ -2758,8 +2756,7 @@ void Node3DEditorViewport::_project_settings_changed() { const Viewport::Scaling3DMode scaling_3d_mode = Viewport::Scaling3DMode(int(GLOBAL_GET("rendering/scaling_3d/mode"))); viewport->set_scaling_3d_mode(scaling_3d_mode); - const float scaling_3d_scale = GLOBAL_GET("rendering/scaling_3d/scale"); - viewport->set_scaling_3d_scale(scaling_3d_scale); + _update_shrink(); const float fsr_sharpness = GLOBAL_GET("rendering/scaling_3d/fsr_sharpness"); viewport->set_fsr_sharpness(fsr_sharpness);