Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Improved region-select in the 3D editor viewport #58252

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions editor/plugins/spatial_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
int gizmo_handle = -1;

clicked = _select_ray(b->get_position(), b->get_shift(), clicked_includes_current, &gizmo_handle, b->get_shift());
selection_in_progress = true;

//clicking is always deferred to either move or release

Expand Down Expand Up @@ -1423,6 +1424,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
surface->update();
}

selection_in_progress = false;
if (_edit.mode != TRANSFORM_NONE) {
static const char *_transform_name[4] = {
TTRC("None"),
Expand Down Expand Up @@ -1513,16 +1515,12 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
nav_mode = NAVIGATION_ORBIT;
} else {
const bool movement_threshold_passed = _edit.original_mouse_pos.distance_to(_edit.mouse_pos) > 8 * EDSCALE;
if (clicked && movement_threshold_passed) {
if (!clicked_includes_current) {
_select_clicked(clicked_wants_append, true);
// Processing was deferred.
if (selection_in_progress && movement_threshold_passed) {
if (get_selected_count() == 0 || clicked_wants_append) {
cursor.region_select = true;
cursor.region_begin = _edit.original_mouse_pos;
clicked = 0;
}

_compute_edit(_edit.mouse_pos);
clicked = 0;

_edit.mode = TRANSFORM_TRANSLATE;
}

if (cursor.region_select) {
Expand All @@ -1531,6 +1529,12 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
return;
}

if (clicked && movement_threshold_passed) {
_compute_edit(_edit.mouse_pos);
clicked = 0;
_edit.mode = TRANSFORM_TRANSLATE;
}

if (_edit.mode == TRANSFORM_NONE) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions editor/plugins/spatial_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ class SpatialEditorViewport : public Control {
Vector<_RayResult> selection_results;
bool clicked_includes_current;
bool clicked_wants_append;
bool selection_in_progress = false;

PopupMenu *selection_menu;

Expand Down