Add a "slow" modifier to freelook

This makes precise adjustments easier, without having to
touch the mouse wheel. This modifier is also available in
Blender, so this makes the freelook behavior more consistent
with it :)

In the interest of simplifying the Editor Settings, this also
removes the freelook modifier speed factor setting
(the value is now hardcoded to its default).
This commit is contained in:
Hugo Locurcio 2019-10-14 22:47:47 +02:00
parent 1fed266bf5
commit af89a87075
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C
2 changed files with 11 additions and 13 deletions

View File

@ -559,8 +559,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["editors/3d/freelook/freelook_base_speed"] = PropertyInfo(Variant::REAL, "editors/3d/freelook/freelook_base_speed", PROPERTY_HINT_RANGE, "0.0, 10, 0.01");
_initial_set("editors/3d/freelook/freelook_activation_modifier", 0);
hints["editors/3d/freelook/freelook_activation_modifier"] = PropertyInfo(Variant::INT, "editors/3d/freelook/freelook_activation_modifier", PROPERTY_HINT_ENUM, "None,Shift,Alt,Meta,Ctrl");
_initial_set("editors/3d/freelook/freelook_modifier_speed_factor", 3.0);
hints["editors/3d/freelook/freelook_modifier_speed_factor"] = PropertyInfo(Variant::REAL, "editors/3d/freelook/freelook_modifier_speed_factor", PROPERTY_HINT_RANGE, "0.0, 10.0, 0.1");
_initial_set("editors/3d/freelook/freelook_speed_zoom_link", false);
// 2D

View File

@ -2049,12 +2049,11 @@ void SpatialEditorViewport::_update_freelook(real_t delta) {
return;
}
Vector3 forward = camera->get_transform().basis.xform(Vector3(0, 0, -1));
Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0));
Vector3 up = camera->get_transform().basis.xform(Vector3(0, 1, 0));
const Vector3 forward = camera->get_transform().basis.xform(Vector3(0, 0, -1));
const Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0));
const Vector3 up = camera->get_transform().basis.xform(Vector3(0, 1, 0));
Vector3 direction;
bool speed_modifier = false;
if (is_shortcut_pressed("spatial_editor/freelook_left")) {
direction -= right;
@ -2074,17 +2073,17 @@ void SpatialEditorViewport::_update_freelook(real_t delta) {
if (is_shortcut_pressed("spatial_editor/freelook_down")) {
direction -= up;
}
if (is_shortcut_pressed("spatial_editor/freelook_speed_modifier")) {
speed_modifier = true;
}
real_t speed = freelook_speed;
if (speed_modifier) {
real_t modifier_speed_factor = EditorSettings::get_singleton()->get("editors/3d/freelook/freelook_modifier_speed_factor");
speed *= modifier_speed_factor;
if (is_shortcut_pressed("spatial_editor/freelook_speed_modifier")) {
speed *= 3.0;
}
if (is_shortcut_pressed("spatial_editor/freelook_slow_modifier")) {
speed *= 0.333333;
}
Vector3 motion = direction * speed * delta;
const Vector3 motion = direction * speed * delta;
cursor.pos += motion;
cursor.eye_pos += motion;
}
@ -3588,6 +3587,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
ED_SHORTCUT("spatial_editor/freelook_up", TTR("Freelook Up"), KEY_E);
ED_SHORTCUT("spatial_editor/freelook_down", TTR("Freelook Down"), KEY_Q);
ED_SHORTCUT("spatial_editor/freelook_speed_modifier", TTR("Freelook Speed Modifier"), KEY_SHIFT);
ED_SHORTCUT("spatial_editor/freelook_slow_modifier", TTR("Freelook Slow Modifier"), KEY_ALT);
preview_camera = memnew(CheckBox);
preview_camera->set_text(TTR("Preview"));