aboutsummaryrefslogtreecommitdiff
path: root/editor/plugins/spatial_editor_plugin.cpp
diff options
context:
space:
mode:
authorJuan Linietsky2017-09-16 12:12:11 -0300
committerJuan Linietsky2017-09-16 12:12:41 -0300
commit844c5e12e664e3212feacc9ee3200e116556fbc7 (patch)
treee7c95622c35ad2aab693526c9bbf892f0b1fbc1f /editor/plugins/spatial_editor_plugin.cpp
parent61e9623ced62d73bf26453e2fc64799e0ee60aa2 (diff)
downloadgodot-844c5e12e664e3212feacc9ee3200e116556fbc7.tar.gz
godot-844c5e12e664e3212feacc9ee3200e116556fbc7.tar.zst
godot-844c5e12e664e3212feacc9ee3200e116556fbc7.zip
Diffstat (limited to 'editor/plugins/spatial_editor_plugin.cpp')
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 704d47474..58e698081 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -76,18 +76,29 @@ void SpatialEditorViewport::_update_camera(float p_interp_delta) {
} else
camera->set_perspective(get_fov(), get_znear(), get_zfar());
- float inertia = EDITOR_DEF("editors/3d/orbit_inertia", 0.5);
- inertia = MAX(0, inertia);
+ //when not being manipulated, move softly
+ float free_orbit_inertia = EDITOR_DEF("editors/3d/free_orbit_inertia", 0.5);
+ float free_translation_inertia = EDITOR_DEF("editors/3d/free_translation_inertia", 0.5);
+ //when being manipulated, move more quickly
+ float manip_orbit_inertia = EDITOR_DEF("editors/3d/manipulation_orbit_inertia", 0.5);
+ float manip_translation_inertia = EDITOR_DEF("editors/3d/manipulation_translation_inertia", 0.5);
+
+ //determine if being manipulated
+ bool manipulated = (Input::get_singleton()->get_mouse_button_mask() & (2 | 4)) || Input::get_singleton()->is_key_pressed(KEY_SHIFT) || Input::get_singleton()->is_key_pressed(KEY_ALT) || Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+
+ float orbit_inertia = MAX(0.00001, manipulated ? manip_orbit_inertia : free_orbit_inertia);
+ float translation_inertia = MAX(0.0001, manipulated ? manip_translation_inertia : free_translation_inertia);
Cursor old_camera_cursor = camera_cursor;
camera_cursor = cursor;
- camera_cursor.x_rot = Math::lerp(old_camera_cursor.x_rot, cursor.x_rot, p_interp_delta * (1 / inertia));
- camera_cursor.y_rot = Math::lerp(old_camera_cursor.y_rot, cursor.y_rot, p_interp_delta * (1 / inertia));
+ camera_cursor.x_rot = Math::lerp(old_camera_cursor.x_rot, cursor.x_rot, MIN(1.0, p_interp_delta * (1 / orbit_inertia)));
+ camera_cursor.y_rot = Math::lerp(old_camera_cursor.y_rot, cursor.y_rot, MIN(1.0, p_interp_delta * (1 / orbit_inertia)));
- bool disable_interp = (Input::get_singleton()->get_mouse_button_mask() & (2 | 4)) || Input::get_singleton()->is_key_pressed(KEY_SHIFT) || Input::get_singleton()->is_key_pressed(KEY_ALT) || Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ camera_cursor.pos = old_camera_cursor.pos.linear_interpolate(cursor.pos, MIN(1.0, p_interp_delta * (1 / translation_inertia)));
+ camera_cursor.distance = Math::lerp(old_camera_cursor.distance, cursor.distance, MIN(1.0, p_interp_delta * (1 / translation_inertia)));
- if (p_interp_delta == 0 || disable_interp || is_freelook_active()) {
+ if (p_interp_delta == 0 || is_freelook_active()) {
camera_cursor = cursor;
}