@@ -240,7 +240,7 @@ void ViewportNavigationControl::_update_navigation() {
240240
241241 Vector3 forward;
242242 if (navigation_scheme == Node3DEditorViewport::FreelookNavigationScheme::FREELOOK_FULLY_AXIS_LOCKED) {
243- // Forward/backward keys will always go straight forward/backward, never moving on the Y axis.
243+ // Forward/backward keys will always go horizontally forward/backward, never moving on the Y axis.
244244 forward = Vector3 (0 , 0 , delta_normalized.y ).rotated (Vector3 (0 , 1 , 0 ), viewport->camera ->get_rotation ().y );
245245 } else {
246246 // Forward/backward keys will be relative to the camera pitch.
@@ -2903,18 +2903,19 @@ void Node3DEditorViewport::_update_freelook(real_t delta) {
29032903 forward = Vector3 (0 , 0 , -1 ).rotated (Vector3 (0 , 1 , 0 ), camera->get_rotation ().y );
29042904 } else {
29052905 // Forward/backward keys will be relative to the camera pitch.
2906- forward = camera->get_transform ().basis .xform ( Vector3 ( 0 , 0 , - 1 ) );
2906+ forward = - camera->get_transform ().basis .get_column ( 2 );
29072907 }
29082908
2909- const Vector3 right = camera->get_transform ().basis .xform ( Vector3 ( 1 , 0 , 0 ) );
2909+ const Vector3 right = camera->get_transform ().basis .get_column ( 0 );
29102910
2911+ Vector3 local_up = camera->get_transform ().basis .get_column (1 );
29112912 Vector3 up;
29122913 if (navigation_scheme == FREELOOK_PARTIALLY_AXIS_LOCKED || navigation_scheme == FREELOOK_FULLY_AXIS_LOCKED) {
29132914 // Up/down keys will always go up/down regardless of camera pitch.
29142915 up = Vector3 (0 , 1 , 0 );
29152916 } else {
29162917 // Up/down keys will be relative to the camera pitch.
2917- up = camera-> get_transform (). basis . xform ( Vector3 ( 0 , 1 , 0 )) ;
2918+ up = local_up ;
29182919 }
29192920
29202921 Vector3 direction;
@@ -2940,6 +2941,18 @@ void Node3DEditorViewport::_update_freelook(real_t delta) {
29402941 if (inp->is_action_pressed (" spatial_editor/freelook_down" )) {
29412942 direction -= up;
29422943 }
2944+ if (inp->is_action_pressed (" spatial_editor/freelook_global_up" )) {
2945+ direction += Vector3 (0 , 1 , 0 );
2946+ }
2947+ if (inp->is_action_pressed (" spatial_editor/freelook_global_down" )) {
2948+ direction -= Vector3 (0 , 1 , 0 );
2949+ }
2950+ if (inp->is_action_pressed (" spatial_editor/freelook_local_up" )) {
2951+ direction += local_up;
2952+ }
2953+ if (inp->is_action_pressed (" spatial_editor/freelook_local_down" )) {
2954+ direction -= local_up;
2955+ }
29432956
29442957 real_t speed = freelook_speed;
29452958
@@ -5675,6 +5688,12 @@ void Node3DEditorViewport::register_shortcut_action(const String &p_path, const
56755688 sc->connect_changed (callable_mp (this , &Node3DEditorViewport::shortcut_changed_callback).bind (sc, p_path));
56765689}
56775690
5691+ void Node3DEditorViewport::register_shortcuts_action (const String &p_path, const String &p_name, const PackedInt32Array &p_keycodes, bool p_physical) {
5692+ Ref<Shortcut> sc = ED_SHORTCUT_ARRAY (p_path, p_name, p_keycodes, p_physical);
5693+ shortcut_changed_callback (sc, p_path);
5694+ sc->connect_changed (callable_mp (this , &Node3DEditorViewport::shortcut_changed_callback).bind (sc, p_path));
5695+ }
5696+
56785697// Update the action in the InputMap to the provided shortcut events.
56795698void Node3DEditorViewport::shortcut_changed_callback (const Ref<Shortcut> p_shortcut, const String &p_shortcut_path) {
56805699 InputMap *im = InputMap::get_singleton ();
@@ -5892,6 +5911,10 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
58925911 register_shortcut_action (" spatial_editor/freelook_backwards" , TTRC (" Freelook Backwards" ), Key::S, true );
58935912 register_shortcut_action (" spatial_editor/freelook_up" , TTRC (" Freelook Up" ), Key::E, true );
58945913 register_shortcut_action (" spatial_editor/freelook_down" , TTRC (" Freelook Down" ), Key::Q, true );
5914+ register_shortcut_action (" spatial_editor/freelook_global_up" , TTRC (" Freelook Global Up" ), Key::SPACE, true );
5915+ register_shortcuts_action (" spatial_editor/freelook_global_down" , TTRC (" Freelook Global Down" ), { int32_t (Key::CTRL), int32_t (Key::META) }, true );
5916+ register_shortcut_action (" spatial_editor/freelook_local_up" , TTRC (" Freelook Local Up" ), Key::R, true );
5917+ register_shortcut_action (" spatial_editor/freelook_local_down" , TTRC (" Freelook Local Down" ), Key::F, true );
58955918 register_shortcut_action (" spatial_editor/freelook_speed_modifier" , TTRC (" Freelook Speed Modifier" ), Key::SHIFT);
58965919 register_shortcut_action (" spatial_editor/freelook_slow_modifier" , TTRC (" Freelook Slow Modifier" ), Key::ALT);
58975920
0 commit comments