diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 320b119b6a8..0164c63b4a4 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -259,11 +259,14 @@ The color to use when drawing smart snapping lines in the 2D editor. The smart snapping lines will automatically display when moving 2D nodes if smart snapping is enabled in the Snapping Options menu at the top of the 2D editor viewport. - If [code]true[/code], the 2D editor will snap to integer zoom values while not holding the [kbd]Alt[/kbd] key and powers of two while holding it. If [code]false[/code], this behavior is swapped. + If [code]true[/code], the 2D editor will snap to integer zoom values when not holding the [kbd]Alt[/kbd] key. If [code]false[/code], this behavior is swapped. The color of the viewport border in the 2D editor. This border represents the viewport's size at the base resolution defined in the Project Settings. Objects placed outside this border will not be visible unless a [Camera2D] node is used, or unless the window is resized and the stretch mode is set to [code]disabled[/code]. + + The factor to use when zooming in or out in the 2D editor. For example, [code]1.1[/code] will zoom in by 10% with every step. If set to [code]2.0[/code], zooming will only cycle through powers of two. + The default camera vertical field of view to use in the 3D editor (in degrees). The camera field of view can be adjusted on a per-scene basis using the [b]View[/b] menu at the top of the 3D editor. If a scene had its camera field of view adjusted using the [b]View[/b] menu, this setting is ignored in the scene in question. This setting is also ignored while a [Camera3D] node is being previewed in the editor. [b]Note:[/b] The editor camera always uses the [b]Keep Height[/b] aspect mode. diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index b9d530353c7..48d0733bc8b 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -766,6 +766,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/2d/bone_outline_size", 2.0, "0.01,8,0.01,or_greater") _initial_set("editors/2d/viewport_border_color", Color(0.4, 0.4, 1.0, 0.4)); _initial_set("editors/2d/use_integer_zoom_by_default", false); + EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/2d/zoom_speed_factor", 1.1, "1.01,2,0.01") // Panning // Enum should be in sync with ControlScheme in ViewPanner. diff --git a/editor/gui/editor_zoom_widget.cpp b/editor/gui/editor_zoom_widget.cpp index 341da7bfaf4..50a4f020abf 100644 --- a/editor/gui/editor_zoom_widget.cpp +++ b/editor/gui/editor_zoom_widget.cpp @@ -141,22 +141,15 @@ void EditorZoomWidget::set_zoom_by_increments(int p_increment_count, bool p_inte } } } else { - // Base increment factor defined as the twelveth root of two. - // This allows for a smooth geometric evolution of the zoom, with the advantage of - // visiting all integer power of two scale factors. - // Note: this is analogous to the 'semitone' interval in the music world - // In order to avoid numerical imprecisions, we compute and edit a zoom index - // with the following relation: zoom = 2 ^ (index / 12) - if (zoom < CMP_EPSILON || p_increment_count == 0) { return; } - // zoom = 2**(index/12) => log2(zoom) = index/12 - float closest_zoom_index = Math::round(Math::log(zoom_noscale) * 12.f / Math::log(2.f)); - - float new_zoom_index = closest_zoom_index + p_increment_count; - float new_zoom = Math::pow(2.f, new_zoom_index / 12.f); + // Zoom is calculated as pow(zoom_factor, zoom_step). + // This ensures the zoom will always equal 100% when zoom_step is 0. + float zoom_factor = EDITOR_GET("editors/2d/zoom_speed_factor"); + float current_zoom_step = Math::round(Math::log(zoom_noscale) / Math::log(zoom_factor)); + float new_zoom = Math::pow(zoom_factor, current_zoom_step + p_increment_count); // Restore Editor scale transformation. new_zoom *= MAX(1, EDSCALE);