View 3D: move picking arguments into a struct & minor refactor

- Add SelectPick_Params struct to make picking logic more
  straightforward and easier to extend.

- Use `eSelectOp` instead of booleans (extend, deselect, toggle)
  which were used to represent 4 states (which wasn't obvious).

- Handle deselect_all when pocking instead of view3d_select_exec,
  de-duplicate de-selection which was already needed in when replacing
  the selection in picking functions.

- Handle outliner update & notifiers in the picking functions
  instead of view3d_select_exec.

- Fix particle select deselect_all option which did nothing.
This commit is contained in:
2022-03-15 21:03:04 +11:00
parent 9a763d24f2
commit 5e5285baf6
20 changed files with 948 additions and 692 deletions

View File

@@ -27,6 +27,7 @@ struct MeshDeformModifierData;
struct Object;
struct ReportList;
struct Scene;
struct SelectPick_Params;
struct UndoType;
struct View3D;
struct ViewLayer;
@@ -164,18 +165,20 @@ bool ED_armature_edit_deselect_all_visible(struct Object *obedit);
bool ED_armature_edit_deselect_all_multi_ex(struct Base **bases, uint bases_len);
bool ED_armature_edit_deselect_all_visible_multi_ex(struct Base **bases, uint bases_len);
bool ED_armature_edit_deselect_all_visible_multi(struct bContext *C);
/**
* \return True when pick finds an element or the selection changed.
*/
bool ED_armature_edit_select_pick_bone(struct bContext *C,
struct Base *basact,
struct EditBone *ebone,
int selmask,
bool extend,
bool deselect,
bool toggle);
const struct SelectPick_Params *params);
/**
* Bone selection picking for armature edit-mode in the view3d.
*/
bool ED_armature_edit_select_pick(
struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
bool ED_armature_edit_select_pick(struct bContext *C,
const int mval[2],
const struct SelectPick_Params *params);
/**
* Perform a selection operation on elements which have been 'touched',
* use for lasso & border select but can be used elsewhere too.
@@ -305,25 +308,26 @@ void ED_pose_recalculate_paths(struct bContext *C,
/* pose_select.c */
void ED_armature_pose_select_pick_bone(struct ViewLayer *view_layer,
/**
* \return True when pick finds an element or the selection changed.
*/
bool ED_armature_pose_select_pick_bone(struct ViewLayer *view_layer,
struct View3D *v3d,
struct Object *ob,
struct Bone *bone,
bool extend,
bool deselect,
bool toggle);
const struct SelectPick_Params *params);
/**
* Called for mode-less pose selection.
* assumes the active object is still on old situation.
*
* \return True when pick finds an element or the selection changed.
*/
bool ED_armature_pose_select_pick_with_buffer(struct ViewLayer *view_layer,
struct View3D *v3d,
struct Base *base,
const struct GPUSelectResult *buffer,
short hits,
bool extend,
bool deselect,
bool toggle,
const struct SelectPick_Params *params,
bool do_nearest);
/**
* While in weight-paint mode, a single pose may be active as well.