Skip to content

Commit a0eb533

Browse files
committed
Add the ability to cancel pan/zoom/orbit navigation
1 parent e37c626 commit a0eb533

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

editor/plugins/node_3d_editor_plugin.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1740,6 +1740,12 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
17401740
} break;
17411741
case MouseButton::RIGHT: {
17421742
if (b->is_pressed()) {
1743+
if(navigating) {
1744+
navigating = false;
1745+
cursor = previous_cursor;
1746+
break;
1747+
}
1748+
17431749
if (_edit.gizmo.is_valid()) {
17441750
// Restore.
17451751
_edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, true);
@@ -2185,6 +2191,13 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
21852191
}
21862192
}
21872193

2194+
if(!navigating && (nav_mode == NAVIGATION_PAN || nav_mode == NAVIGATION_ZOOM || nav_mode == NAVIGATION_ORBIT)) {
2195+
navigating = true;
2196+
previous_cursor = cursor;
2197+
} else if(navigating && (nav_mode == NAVIGATION_NONE || nav_mode == NAVIGATION_LOOK)) {
2198+
navigating = false;
2199+
}
2200+
21882201
switch (nav_mode) {
21892202
case NAVIGATION_PAN: {
21902203
_nav_pan(m, _get_warped_mouse_motion(m));
@@ -2319,7 +2332,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
23192332
_edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, true);
23202333
_edit.gizmo = Ref<EditorNode3DGizmo>();
23212334
}
2322-
if (k->get_keycode() == Key::ESCAPE && !cursor.region_select) {
2335+
if (k->get_keycode() == Key::ESCAPE && !cursor.region_select && !navigating) {
23232336
_clear_selected();
23242337
return;
23252338
}
@@ -2496,6 +2509,11 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
24962509
set_freelook_active(!is_freelook_active());
24972510

24982511
} else if (k->get_keycode() == Key::ESCAPE) {
2512+
if(navigating) {
2513+
navigating = false;
2514+
cursor = previous_cursor;
2515+
return;
2516+
}
24992517
set_freelook_active(false);
25002518
}
25012519

editor/plugins/node_3d_editor_plugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ class Node3DEditorViewport : public Control {
439439
};
440440

441441
NavigationMode _get_nav_mode_from_shortcut_check(ViewportNavMouseButton p_mouse_button, Vector<ShortcutCheckSet> p_shortcut_check_sets, bool p_use_not_empty);
442+
bool navigating = false;
442443

443444
void set_freelook_active(bool active_now);
444445
void scale_freelook_speed(real_t scale);

0 commit comments

Comments
 (0)