Particle editmode: add mouse independent "Select Linked" operator
The current "Select Linked" operator works based on mouse position and makes no sense to call from the menus and was removed in rBdd9dfadaac9b. This patch adds an operator independent from mouse position that just selects all keys to a corresponding point (and adds back menu entries, adds keymap entry). The original operator is renamed to 'select_linked_pick' internally (this is now more in line to how "Select Linked" works for meshes, curves etc) Differential Revision: https://developer.blender.org/D6823
This commit is contained in:
parent
d9e4f5a7e8
commit
5ca7c85e10
Notes:
blender-bot
2023-02-14 05:04:52 +01:00
Referenced by commit 536055e1ee
, remove "Select Linked" from the posemode select menu
Referenced by issue #76071, Pose: Select Linked does not work from menu
|
@ -4264,10 +4264,11 @@ def km_particle(params):
|
|||
*_template_items_select_actions(params, "particle.select_all"),
|
||||
("particle.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
|
||||
("particle.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
|
||||
("particle.select_linked", {"type": 'L', "value": 'PRESS'},
|
||||
("particle.select_linked_pick", {"type": 'L', "value": 'PRESS'},
|
||||
{"properties": [("deselect", False)]}),
|
||||
("particle.select_linked", {"type": 'L', "value": 'PRESS', "shift": True},
|
||||
("particle.select_linked_pick", {"type": 'L', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("deselect", True)]}),
|
||||
("particle.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
|
||||
("particle.delete", {"type": 'X', "value": 'PRESS'}, None),
|
||||
("particle.delete", {"type": 'DEL', "value": 'PRESS'}, None),
|
||||
("particle.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None),
|
||||
|
|
|
@ -3278,10 +3278,11 @@ def km_particle(params):
|
|||
("particle.select_all", {"type": 'I', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'INVERT')]}),
|
||||
("particle.select_more", {"type": 'UP_ARROW', "value": 'PRESS'}, None),
|
||||
("particle.select_less", {"type": 'DOWN_ARROW', "value": 'PRESS'}, None),
|
||||
("particle.select_linked", {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
|
||||
("particle.select_linked_pick", {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
|
||||
{"properties": [("deselect", False)]}),
|
||||
("particle.select_linked", {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True},
|
||||
("particle.select_linked_pick", {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("deselect", True)]}),
|
||||
("particle.select_linked", {"type": 'RIGHT_BRACKET', "value": 'PRESS', "ctrl": True}, None),
|
||||
("particle.delete", {"type": 'BACK_SPACE', "value": 'PRESS'}, None),
|
||||
("particle.delete", {"type": 'DEL', "value": 'PRESS'}, None),
|
||||
("particle.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None),
|
||||
|
|
|
@ -1443,6 +1443,10 @@ class VIEW3D_MT_select_particle(Menu):
|
|||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("particle.select_linked", text="Select Linked")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("particle.select_more")
|
||||
layout.operator("particle.select_less")
|
||||
|
||||
|
@ -3120,6 +3124,9 @@ class VIEW3D_MT_particle_context_menu(Menu):
|
|||
layout.operator("particle.select_more")
|
||||
layout.operator("particle.select_less")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("particle.select_linked", text="Select Linked")
|
||||
|
||||
class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
|
||||
_operator_name = "particle"
|
||||
|
|
|
@ -2075,7 +2075,38 @@ void PARTICLE_OT_select_random(wmOperatorType *ot)
|
|||
|
||||
/************************ select linked operator ************************/
|
||||
|
||||
static int select_linked_exec(bContext *C, wmOperator *op)
|
||||
static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
PEData data;
|
||||
PE_set_data(C, &data);
|
||||
data.select = true;
|
||||
|
||||
foreach_selected_key(&data, select_keys);
|
||||
|
||||
PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, data.ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void PARTICLE_OT_select_linked(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Select Linked All";
|
||||
ot->idname = "PARTICLE_OT_select_linked";
|
||||
ot->description = "Select all keys linked to already selected ones";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = select_linked_exec;
|
||||
ot->poll = PE_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
}
|
||||
|
||||
static int select_linked_pick_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
PEData data;
|
||||
int mval[2];
|
||||
|
@ -2097,22 +2128,22 @@ static int select_linked_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int select_linked_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
static int select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
RNA_int_set_array(op->ptr, "location", event->mval);
|
||||
return select_linked_exec(C, op);
|
||||
return select_linked_pick_exec(C, op);
|
||||
}
|
||||
|
||||
void PARTICLE_OT_select_linked(wmOperatorType *ot)
|
||||
void PARTICLE_OT_select_linked_pick(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Select Linked";
|
||||
ot->idname = "PARTICLE_OT_select_linked";
|
||||
ot->idname = "PARTICLE_OT_select_linked_pick";
|
||||
ot->description = "Select nearest particle from mouse pointer";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = select_linked_exec;
|
||||
ot->invoke = select_linked_invoke;
|
||||
ot->exec = select_linked_pick_exec;
|
||||
ot->invoke = select_linked_pick_invoke;
|
||||
ot->poll = PE_poll_view3d;
|
||||
|
||||
/* flags */
|
||||
|
|
|
@ -38,6 +38,7 @@ void PARTICLE_OT_select_roots(struct wmOperatorType *ot);
|
|||
void PARTICLE_OT_select_tips(struct wmOperatorType *ot);
|
||||
void PARTICLE_OT_select_random(struct wmOperatorType *ot);
|
||||
void PARTICLE_OT_select_linked(struct wmOperatorType *ot);
|
||||
void PARTICLE_OT_select_linked_pick(struct wmOperatorType *ot);
|
||||
void PARTICLE_OT_select_less(struct wmOperatorType *ot);
|
||||
void PARTICLE_OT_select_more(struct wmOperatorType *ot);
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ static void operatortypes_particle(void)
|
|||
WM_operatortype_append(PARTICLE_OT_select_tips);
|
||||
WM_operatortype_append(PARTICLE_OT_select_random);
|
||||
WM_operatortype_append(PARTICLE_OT_select_linked);
|
||||
WM_operatortype_append(PARTICLE_OT_select_linked_pick);
|
||||
WM_operatortype_append(PARTICLE_OT_select_less);
|
||||
WM_operatortype_append(PARTICLE_OT_select_more);
|
||||
|
||||
|
|
Loading…
Reference in New Issue