You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Added configurable modifier key to activate freelook
This commit is contained in:
@@ -30,7 +30,6 @@
|
|||||||
#include "editor_settings.h"
|
#include "editor_settings.h"
|
||||||
|
|
||||||
#include "editor_node.h"
|
#include "editor_node.h"
|
||||||
#include "project_settings.h"
|
|
||||||
#include "io/compression.h"
|
#include "io/compression.h"
|
||||||
#include "io/config_file.h"
|
#include "io/config_file.h"
|
||||||
#include "io/file_access_memory.h"
|
#include "io/file_access_memory.h"
|
||||||
@@ -41,6 +40,7 @@
|
|||||||
#include "os/file_access.h"
|
#include "os/file_access.h"
|
||||||
#include "os/keyboard.h"
|
#include "os/keyboard.h"
|
||||||
#include "os/os.h"
|
#include "os/os.h"
|
||||||
|
#include "project_settings.h"
|
||||||
#include "scene/main/node.h"
|
#include "scene/main/node.h"
|
||||||
#include "scene/main/scene_tree.h"
|
#include "scene/main/scene_tree.h"
|
||||||
#include "scene/main/viewport.h"
|
#include "scene/main/viewport.h"
|
||||||
@@ -638,6 +638,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
|||||||
set("editors/3d/warped_mouse_panning", true);
|
set("editors/3d/warped_mouse_panning", true);
|
||||||
|
|
||||||
set("editors/3d/freelook_base_speed", 1);
|
set("editors/3d/freelook_base_speed", 1);
|
||||||
|
|
||||||
|
set("editors/3d/freelook_activation_modifier", 0);
|
||||||
|
hints["editors/3d/freelook_activation_modifier"] = PropertyInfo(Variant::INT, "editors/3d/freelook_activation_modifier", PROPERTY_HINT_ENUM, "None,Shift,Alt,Meta,Ctrl");
|
||||||
|
|
||||||
set("editors/3d/freelook_modifier_speed_factor", 5.0);
|
set("editors/3d/freelook_modifier_speed_factor", 5.0);
|
||||||
|
|
||||||
set("editors/2d/bone_width", 5);
|
set("editors/2d/bone_width", 5);
|
||||||
|
|||||||
@@ -36,9 +36,9 @@
|
|||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
#include "editor/plugins/animation_player_editor_plugin.h"
|
#include "editor/plugins/animation_player_editor_plugin.h"
|
||||||
#include "editor/spatial_editor_gizmos.h"
|
#include "editor/spatial_editor_gizmos.h"
|
||||||
#include "project_settings.h"
|
|
||||||
#include "os/keyboard.h"
|
#include "os/keyboard.h"
|
||||||
#include "print_string.h"
|
#include "print_string.h"
|
||||||
|
#include "project_settings.h"
|
||||||
#include "scene/3d/camera.h"
|
#include "scene/3d/camera.h"
|
||||||
#include "scene/3d/visual_instance.h"
|
#include "scene/3d/visual_instance.h"
|
||||||
#include "scene/resources/surface_tool.h"
|
#include "scene/resources/surface_tool.h"
|
||||||
@@ -518,7 +518,7 @@ void SpatialEditorViewport::_compute_edit(const Point2 &p_point) {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _get_key_modifier(const String &p_property) {
|
static int _get_key_modifier_setting(const String &p_property) {
|
||||||
|
|
||||||
switch (EditorSettings::get_singleton()->get(p_property).operator int()) {
|
switch (EditorSettings::get_singleton()->get(p_property).operator int()) {
|
||||||
|
|
||||||
@@ -531,6 +531,18 @@ static int _get_key_modifier(const String &p_property) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _get_key_modifier(Ref<InputEventWithModifiers> e) {
|
||||||
|
if (e->get_shift())
|
||||||
|
return KEY_SHIFT;
|
||||||
|
if (e->get_alt())
|
||||||
|
return KEY_ALT;
|
||||||
|
if (e->get_control())
|
||||||
|
return KEY_CONTROL;
|
||||||
|
if (e->get_metakey())
|
||||||
|
return KEY_META;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) {
|
bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) {
|
||||||
|
|
||||||
if (!spatial_editor->is_gizmo_visible())
|
if (!spatial_editor->is_gizmo_visible())
|
||||||
@@ -774,7 +786,15 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
|||||||
set_message(TTR("Transform Aborted."), 3);
|
set_message(TTR("Transform Aborted."), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
freelook_active = b->is_pressed();
|
if (b->is_pressed()) {
|
||||||
|
int mod = _get_key_modifier(b);
|
||||||
|
if (mod == _get_key_modifier_setting("editors/3d/freelook_activation_modifier")) {
|
||||||
|
freelook_active = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
freelook_active = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (freelook_active && !surface->has_focus()) {
|
if (freelook_active && !surface->has_focus()) {
|
||||||
// Focus usually doesn't trigger on right-click, but in case of freelook it should,
|
// Focus usually doesn't trigger on right-click, but in case of freelook it should,
|
||||||
// otherwise using keyboard navigation would misbehave
|
// otherwise using keyboard navigation would misbehave
|
||||||
@@ -1297,7 +1317,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
|||||||
|
|
||||||
if (nav_scheme == NAVIGATION_MAYA && m->get_alt()) {
|
if (nav_scheme == NAVIGATION_MAYA && m->get_alt()) {
|
||||||
nav_mode = NAVIGATION_ZOOM;
|
nav_mode = NAVIGATION_ZOOM;
|
||||||
} else {
|
} else if (freelook_active) {
|
||||||
nav_mode = NAVIGATION_LOOK;
|
nav_mode = NAVIGATION_LOOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1305,21 +1325,13 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
|||||||
|
|
||||||
if (nav_scheme == NAVIGATION_GODOT) {
|
if (nav_scheme == NAVIGATION_GODOT) {
|
||||||
|
|
||||||
int mod = 0;
|
int mod = _get_key_modifier(m);
|
||||||
if (m->get_shift())
|
|
||||||
mod = KEY_SHIFT;
|
|
||||||
if (m->get_alt())
|
|
||||||
mod = KEY_ALT;
|
|
||||||
if (m->get_control())
|
|
||||||
mod = KEY_CONTROL;
|
|
||||||
if (m->get_metakey())
|
|
||||||
mod = KEY_META;
|
|
||||||
|
|
||||||
if (mod == _get_key_modifier("editors/3d/pan_modifier"))
|
if (mod == _get_key_modifier_setting("editors/3d/pan_modifier"))
|
||||||
nav_mode = NAVIGATION_PAN;
|
nav_mode = NAVIGATION_PAN;
|
||||||
else if (mod == _get_key_modifier("editors/3d/zoom_modifier"))
|
else if (mod == _get_key_modifier_setting("editors/3d/zoom_modifier"))
|
||||||
nav_mode = NAVIGATION_ZOOM;
|
nav_mode = NAVIGATION_ZOOM;
|
||||||
else if (mod == _get_key_modifier("editors/3d/orbit_modifier"))
|
else if (mod == _get_key_modifier_setting("editors/3d/orbit_modifier"))
|
||||||
nav_mode = NAVIGATION_ORBIT;
|
nav_mode = NAVIGATION_ORBIT;
|
||||||
|
|
||||||
} else if (nav_scheme == NAVIGATION_MAYA) {
|
} else if (nav_scheme == NAVIGATION_MAYA) {
|
||||||
@@ -1329,22 +1341,14 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
|||||||
|
|
||||||
} else if (EditorSettings::get_singleton()->get("editors/3d/emulate_3_button_mouse")) {
|
} else if (EditorSettings::get_singleton()->get("editors/3d/emulate_3_button_mouse")) {
|
||||||
// Handle trackpad (no external mouse) use case
|
// Handle trackpad (no external mouse) use case
|
||||||
int mod = 0;
|
int mod = _get_key_modifier(m);
|
||||||
if (m->get_shift())
|
|
||||||
mod = KEY_SHIFT;
|
|
||||||
if (m->get_alt())
|
|
||||||
mod = KEY_ALT;
|
|
||||||
if (m->get_control())
|
|
||||||
mod = KEY_CONTROL;
|
|
||||||
if (m->get_metakey())
|
|
||||||
mod = KEY_META;
|
|
||||||
|
|
||||||
if (mod) {
|
if (mod) {
|
||||||
if (mod == _get_key_modifier("editors/3d/pan_modifier"))
|
if (mod == _get_key_modifier_setting("editors/3d/pan_modifier"))
|
||||||
nav_mode = NAVIGATION_PAN;
|
nav_mode = NAVIGATION_PAN;
|
||||||
else if (mod == _get_key_modifier("editors/3d/zoom_modifier"))
|
else if (mod == _get_key_modifier_setting("editors/3d/zoom_modifier"))
|
||||||
nav_mode = NAVIGATION_ZOOM;
|
nav_mode = NAVIGATION_ZOOM;
|
||||||
else if (mod == _get_key_modifier("editors/3d/orbit_modifier"))
|
else if (mod == _get_key_modifier_setting("editors/3d/orbit_modifier"))
|
||||||
nav_mode = NAVIGATION_ORBIT;
|
nav_mode = NAVIGATION_ORBIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user