mirror of
https://github.com/godotengine/godot.git
synced 2025-01-12 20:22:49 +08:00
Merge pull request #32841 from Calinou/freelook-add-slow-modifier
Add a "slow" modifier to freelook
This commit is contained in:
commit
ee3b28e9af
@ -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
|
||||
|
@ -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"));
|
||||
|
Loading…
Reference in New Issue
Block a user