From 3c10de2c9b49589d2943ffb5b235e7930f3a4d17 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Mar 2019 23:09:22 +1100 Subject: 3D View: avoid redundant circle select updates This refreshes on cursor motion so it's worth avoiding redundant updates, especially for multi-object edit-modes where many objects aren't even near the object being selected. This commit also moves to passing eSelectOp to circle select functions in preparation for adding a select mode tool option. --- source/blender/editors/physics/particle_edit.c | 29 +++++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'source/blender/editors/physics') diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index cc96fba6ba8..f9b30de5dc5 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -425,6 +425,7 @@ typedef struct PEData { int select_action; int select_toggle_action; + bool is_changed; } PEData; static void PE_set_data(bContext *C, PEData *data) @@ -1516,6 +1517,7 @@ static void select_key(PEData *data, int point_index, int key_index, bool UNUSED key->flag &= ~PEK_SELECT; point->flag |= PEP_EDIT_RECALC; + data->is_changed = true; } static void select_key_op(PEData *data, int point_index, int key_index, bool is_inside) @@ -1998,27 +2000,38 @@ int PE_box_select(bContext *C, const rcti *rect, const int sel_op) /************************ circle select operator ************************/ -int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad) +bool PE_circle_select(bContext *C, const int sel_op, const int mval[2], float rad) { + BLI_assert(ELEM(sel_op, SEL_OP_SET, SEL_OP_ADD, SEL_OP_SUB)); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); PTCacheEdit *edit = PE_get_current(scene, ob); PEData data; - if (!PE_start_edit(edit)) - return OPERATOR_FINISHED; + if (!PE_start_edit(edit)) { + return false; + } + + bool changed = false; + if (SEL_OP_USE_PRE_DESELECT(sel_op)) { + PE_deselect_all_visible(edit); + changed = true; + } + const bool select = (sel_op != SEL_OP_SUB); PE_set_view3d_data(C, &data); data.mval = mval; data.rad = rad; - data.select = selecting; + data.select = select; for_mouse_hit_keys(&data, select_key, 0); + changed |= data.is_changed; - PE_update_selection(data.depsgraph, scene, ob, 1); - WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, ob); - - return OPERATOR_FINISHED; + if (changed) { + PE_update_selection(data.depsgraph, scene, ob, 1); + WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, ob); + } + return changed; } /************************ lasso select operator ************************/ -- cgit v1.2.3