Skip to content

Commit

Permalink
Make 3D transforms done inside editor viewport, but w/o grabbing a gi…
Browse files Browse the repository at this point in the history
…zmo handle require pressing alt
  • Loading branch information
ryevdokimov committed Feb 6, 2024
1 parent d335281 commit 4b549b1
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,23 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {

clicked = ObjectID();

if (after != EditorPlugin::AFTER_GUI_INPUT_CUSTOM && !b->is_alt_pressed()) {
//clicking is always deferred to either move or release
clicked = _select_ray(b->get_position());
if (clicked.is_valid() && !editor_selection->is_selected(Object::cast_to<Node>(ObjectDB::get_instance(clicked)))) {
selection_in_progress = true;
break;
}

if (clicked.is_null()) {
//default to regionselect
cursor.region_select = true;
cursor.region_begin = b->get_position();
cursor.region_end = b->get_position();
break;
}
}

bool node_selected = get_selected_count() > 0;

if (node_selected && ((spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT && b->is_command_or_control_pressed()) || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE)) {
Expand All @@ -1855,21 +1872,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
begin_transform(TRANSFORM_SCALE, false);
break;
}

if (after != EditorPlugin::AFTER_GUI_INPUT_CUSTOM) {
//clicking is always deferred to either move or release
clicked = _select_ray(b->get_position());
selection_in_progress = true;

if (clicked.is_null()) {
//default to regionselect
cursor.region_select = true;
cursor.region_begin = b->get_position();
cursor.region_end = b->get_position();
}
}

surface->queue_redraw();
} else {
if (_edit.gizmo.is_valid()) {
_edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, false);
Expand Down Expand Up @@ -1912,7 +1914,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
set_message("");
spatial_editor->update_transform_gizmo();
}
surface->queue_redraw();
}

} break;
Expand Down Expand Up @@ -1986,12 +1987,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} else {
const bool movement_threshold_passed = _edit.original_mouse_pos.distance_to(_edit.mouse_pos) > 8 * EDSCALE;

if (selection_in_progress && movement_threshold_passed && clicked.is_valid()) {
if (clicked_wants_append || !editor_selection->is_selected(Object::cast_to<Node>(ObjectDB::get_instance(clicked)))) {
cursor.region_select = true;
cursor.region_begin = _edit.original_mouse_pos;
clicked = ObjectID();
}
if ((selection_in_progress || clicked_wants_append) && movement_threshold_passed && clicked.is_valid()) {
cursor.region_select = true;
cursor.region_begin = _edit.original_mouse_pos;
clicked = ObjectID();
}

if (cursor.region_select) {
Expand All @@ -2000,7 +1999,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
return;
}

if (clicked.is_valid() && movement_threshold_passed) {
if (clicked.is_valid() && movement_threshold_passed && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE)) {
_compute_edit(_edit.original_mouse_pos);
clicked = ObjectID();
_edit.mode = TRANSFORM_TRANSLATE;
Expand All @@ -2010,7 +2009,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
return;
}

update_transform(_get_key_modifier(m) == Key::SHIFT);
if (!selection_in_progress) {
update_transform(_get_key_modifier(m) == Key::SHIFT);
}
}
} else if (m->get_button_mask().has_flag(MouseButtonMask::RIGHT) || freelook_active) {
if (nav_scheme == NAVIGATION_MAYA && m->is_alt_pressed()) {
Expand Down

0 comments on commit 4b549b1

Please sign in to comment.