@@ -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.
@@ -2776,18 +2776,19 @@ void Node3DEditorViewport::_update_freelook(real_t delta) {
27762776 forward = Vector3 (0 , 0 , -1 ).rotated (Vector3 (0 , 1 , 0 ), camera->get_rotation ().y );
27772777 } else {
27782778 // Forward/backward keys will be relative to the camera pitch.
2779- forward = camera->get_transform ().basis .xform ( Vector3 ( 0 , 0 , - 1 ) );
2779+ forward = - camera->get_transform ().basis .get_column ( 2 );
27802780 }
27812781
2782- const Vector3 right = camera->get_transform ().basis .xform ( Vector3 ( 1 , 0 , 0 ) );
2782+ const Vector3 right = camera->get_transform ().basis .get_column ( 0 );
27832783
2784+ Vector3 local_up = camera->get_transform ().basis .get_column (1 );
27842785 Vector3 up;
27852786 if (navigation_scheme == FREELOOK_PARTIALLY_AXIS_LOCKED || navigation_scheme == FREELOOK_FULLY_AXIS_LOCKED) {
27862787 // Up/down keys will always go up/down regardless of camera pitch.
27872788 up = Vector3 (0 , 1 , 0 );
27882789 } else {
27892790 // Up/down keys will be relative to the camera pitch.
2790- up = camera-> get_transform (). basis . xform ( Vector3 ( 0 , 1 , 0 )) ;
2791+ up = local_up ;
27912792 }
27922793
27932794 Vector3 direction;
@@ -2813,6 +2814,18 @@ void Node3DEditorViewport::_update_freelook(real_t delta) {
28132814 if (inp->is_action_pressed (" spatial_editor/freelook_down" )) {
28142815 direction -= up;
28152816 }
2817+ if (inp->is_action_pressed (" spatial_editor/freelook_global_up" )) {
2818+ direction += Vector3 (0 , 1 , 0 );
2819+ }
2820+ if (inp->is_action_pressed (" spatial_editor/freelook_global_down" )) {
2821+ direction -= Vector3 (0 , 1 , 0 );
2822+ }
2823+ if (inp->is_action_pressed (" spatial_editor/freelook_local_up" )) {
2824+ direction += local_up;
2825+ }
2826+ if (inp->is_action_pressed (" spatial_editor/freelook_local_down" )) {
2827+ direction -= local_up;
2828+ }
28162829
28172830 real_t speed = freelook_speed;
28182831
@@ -5462,6 +5475,12 @@ void Node3DEditorViewport::register_shortcut_action(const String &p_path, const
54625475 sc->connect_changed (callable_mp (this , &Node3DEditorViewport::shortcut_changed_callback).bind (sc, p_path));
54635476}
54645477
5478+ void Node3DEditorViewport::register_shortcuts_action (const String &p_path, const String &p_name, const PackedInt32Array &p_keycodes, bool p_physical) {
5479+ Ref<Shortcut> sc = ED_SHORTCUT_ARRAY (p_path, p_name, p_keycodes, p_physical);
5480+ shortcut_changed_callback (sc, p_path);
5481+ sc->connect_changed (callable_mp (this , &Node3DEditorViewport::shortcut_changed_callback).bind (sc, p_path));
5482+ }
5483+
54655484// Update the action in the InputMap to the provided shortcut events.
54665485void Node3DEditorViewport::shortcut_changed_callback (const Ref<Shortcut> p_shortcut, const String &p_shortcut_path) {
54675486 InputMap *im = InputMap::get_singleton ();
@@ -5666,6 +5685,10 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
56665685 register_shortcut_action (" spatial_editor/freelook_backwards" , TTRC (" Freelook Backwards" ), Key::S, true );
56675686 register_shortcut_action (" spatial_editor/freelook_up" , TTRC (" Freelook Up" ), Key::E, true );
56685687 register_shortcut_action (" spatial_editor/freelook_down" , TTRC (" Freelook Down" ), Key::Q, true );
5688+ register_shortcut_action (" spatial_editor/freelook_global_up" , TTRC (" Freelook Global Up" ), Key::SPACE, true );
5689+ register_shortcuts_action (" spatial_editor/freelook_global_down" , TTRC (" Freelook Global Down" ), { int32_t (Key::CTRL), int32_t (Key::META) }, true );
5690+ register_shortcut_action (" spatial_editor/freelook_local_up" , TTRC (" Freelook Local Up" ), Key::R, true );
5691+ register_shortcut_action (" spatial_editor/freelook_local_down" , TTRC (" Freelook Local Down" ), Key::F, true );
56695692 register_shortcut_action (" spatial_editor/freelook_speed_modifier" , TTRC (" Freelook Speed Modifier" ), Key::SHIFT);
56705693 register_shortcut_action (" spatial_editor/freelook_slow_modifier" , TTRC (" Freelook Slow Modifier" ), Key::ALT);
56715694
0 commit comments