diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-12-27 09:46:55 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-12-27 10:01:11 +0300 |
commit | f820c45534c653c7a2baa799b99067710def136b (patch) | |
tree | 7f08c2e1fa8e5aa2dbdbe38c64a1684495df124f /source/blender/editors/mesh/editmesh_select.c | |
parent | b254905c384d87764cd92ed631f86f3f97caa4de (diff) |
WM: add checker_interval utility functions
Diffstat (limited to 'source/blender/editors/mesh/editmesh_select.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index f318c38e3bb..fba775518c7 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -3162,7 +3162,9 @@ static bool bm_edge_is_select_isolated(BMEdge *e) /* Walk all reachable elements of the same type as h_act in breadth-first * order, starting from h_act. Deselects elements if the depth when they * are reached is not a multiple of "nth". */ -static void walker_deselect_nth(BMEditMesh *em, int nth, int skip, int offset, BMHeader *h_act) +static void walker_deselect_nth( + BMEditMesh *em, const struct CheckerIntervalParams *op_params, + BMHeader *h_act) { BMElem *ele; BMesh *bm = em->bm; @@ -3229,7 +3231,7 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int skip, int offset, B if (!BM_elem_flag_test(ele, BM_ELEM_TAG)) { /* Deselect elements that aren't at "nth" depth from active */ const int depth = BMW_current_depth(&walker) - 1; - if ((offset + depth) % (skip + nth) >= skip) { + if (WM_operator_properties_checker_interval_test(op_params, depth)) { BM_elem_select_set(bm, ele, false); } BM_elem_flag_enable(ele, BM_ELEM_TAG); @@ -3296,7 +3298,7 @@ static void deselect_nth_active(BMEditMesh *em, BMVert **r_eve, BMEdge **r_eed, } } -static bool edbm_deselect_nth(BMEditMesh *em, int nth, int skip, int offset) +static bool edbm_deselect_nth(BMEditMesh *em, const struct CheckerIntervalParams *op_params) { BMVert *v; BMEdge *e; @@ -3305,15 +3307,15 @@ static bool edbm_deselect_nth(BMEditMesh *em, int nth, int skip, int offset) deselect_nth_active(em, &v, &e, &f); if (v) { - walker_deselect_nth(em, nth, skip, offset, &v->head); + walker_deselect_nth(em, op_params, &v->head); return true; } else if (e) { - walker_deselect_nth(em, nth, skip, offset, &e->head); + walker_deselect_nth(em, op_params, &e->head); return true; } else if (f) { - walker_deselect_nth(em, nth, skip, offset, &f->head); + walker_deselect_nth(em, op_params, &f->head); return true; } @@ -3324,14 +3326,11 @@ static int edbm_select_nth_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); - const int nth = RNA_int_get(op->ptr, "nth") - 1; - const int skip = RNA_int_get(op->ptr, "skip"); - int offset = RNA_int_get(op->ptr, "offset"); + struct CheckerIntervalParams op_params; - /* so input of offset zero ends up being (nth - 1) */ - offset = mod_i(offset, nth + skip); + WM_operator_properties_checker_interval_from_op(op, &op_params); - if (edbm_deselect_nth(em, nth, skip, offset) == 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; } @@ -3356,9 +3355,7 @@ void MESH_OT_select_nth(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_int(ot->srna, "nth", 2, 2, INT_MAX, "Nth Selection", "", 2, 100); - RNA_def_int(ot->srna, "skip", 1, 1, INT_MAX, "Skip", "", 1, 100); - RNA_def_int(ot->srna, "offset", 0, INT_MIN, INT_MAX, "Offset", "", -100, 100); + WM_operator_properties_checker_interval(ot, false); } void em_setup_viewcontext(bContext *C, ViewContext *vc) |