diff options
author | Luc Revardel <luc.revardel@gmail.com> | 2018-05-14 14:57:17 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-05-14 15:07:10 +0300 |
commit | 63c23971717d8a578e737c26796b92479c160f23 (patch) | |
tree | c511861ab6b6fdcee89cccfec07ab18a532c1400 /source/blender/editors/mesh/editmesh_select.c | |
parent | e33016c77ef2727247a2b11b04554a7ea941c94d (diff) |
T54643-Multi-Object EditMesh: MESH_OT_select_nth
With changes by Dalai Felinto:
* Move WM_operator.* outside for loop.
* Update error message to handle Mesh and Meshes.
* Skip main functionality when no vert/edge/face is selected.
Maniphest Tasks: T54643
Differential Revision: https://developer.blender.org/D3371
Diffstat (limited to 'source/blender/editors/mesh/editmesh_select.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 0f25624a1f9..a232deed688 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -3728,18 +3728,39 @@ static bool edbm_deselect_nth(BMEditMesh *em, const struct CheckerIntervalParams static int edbm_select_nth_exec(bContext *C, wmOperator *op) { - Object *obedit = CTX_data_edit_object(C); - BMEditMesh *em = BKE_editmesh_from_object(obedit); + ViewLayer *view_layer = CTX_data_view_layer(C); struct CheckerIntervalParams op_params; - WM_operator_properties_checker_interval_from_op(op, &op_params); + bool found_active_elt = false; - if (edbm_deselect_nth(em, &op_params) == false) { - BKE_report(op->reports, RPT_ERROR, "Mesh has no active vert/edge/face"); - return OPERATOR_CANCELLED; + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + BMEditMesh *em = BKE_editmesh_from_object(obedit); + + if ((em->bm->totvertsel == 0) && + (em->bm->totedgesel == 0) && + (em->bm->totfacesel == 0)) + { + continue; + } + + if (edbm_deselect_nth(em, &op_params) == true) { + found_active_elt = true; + EDBM_update_generic(em, false, false); + } } + MEM_SAFE_FREE(objects); - EDBM_update_generic(em, false, false); + if (!found_active_elt) { + BKE_report(op->reports, RPT_ERROR, + (objects_len == 1 ? + "Mesh has no active vert/edge/face" : + "Meshes have no active vert/edge/face")); + return OPERATOR_CANCELLED; + } return OPERATOR_FINISHED; } |