diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-10-24 02:38:30 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-10-24 02:38:30 +0300 |
commit | 9f1857002e2b28dfd71e9237b2e92b873f87d082 (patch) | |
tree | ac84f5872bc7cb896d2fa5ec5fcf340680b856e7 | |
parent | c052d38d0a59478035151af8c5cf9267c7414933 (diff) |
Multi-Objects: LATTICE_OT_select_more/less
Note: Those operators are yet to be added to the menu.
-rw-r--r-- | source/blender/editors/lattice/editlattice_select.c | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c index 5ff8ae76c3d..8ab0dc3f6b8 100644 --- a/source/blender/editors/lattice/editlattice_select.c +++ b/source/blender/editors/lattice/editlattice_select.c @@ -266,43 +266,53 @@ static bool lattice_test_bitmap_uvw(Lattice *lt, BLI_bitmap *selpoints, int u, i static int lattice_select_more_less(bContext *C, const bool select) { - Object *obedit = CTX_data_edit_object(C); - Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt; - BPoint *bp; - const int tot = lt->pntsu * lt->pntsv * lt->pntsw; - int u, v, w; - BLI_bitmap *selpoints; + ViewLayer *view_layer = CTX_data_view_layer(C); + uint objects_len; + bool changed = false; - lt->actbp = LT_ACTBP_NONE; + 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]; + Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt; + BPoint *bp; + const int tot = lt->pntsu * lt->pntsv * lt->pntsw; + int u, v, w; + BLI_bitmap *selpoints; - selpoints = BLI_BITMAP_NEW(tot, __func__); - BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false); + lt->actbp = LT_ACTBP_NONE; + + selpoints = BLI_BITMAP_NEW(tot, __func__); + BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false); - bp = lt->def; - for (w = 0; w < lt->pntsw; w++) { - for (v = 0; v < lt->pntsv; v++) { - for (u = 0; u < lt->pntsu; u++) { - if ((bp->hide == 0) && (((bp->f1 & SELECT) == 0) == select)) { - if (lattice_test_bitmap_uvw(lt, selpoints, u + 1, v, w, select) || - lattice_test_bitmap_uvw(lt, selpoints, u - 1, v, w, select) || - lattice_test_bitmap_uvw(lt, selpoints, u, v + 1, w, select) || - lattice_test_bitmap_uvw(lt, selpoints, u, v - 1, w, select) || - lattice_test_bitmap_uvw(lt, selpoints, u, v, w + 1, select) || - lattice_test_bitmap_uvw(lt, selpoints, u, v, w - 1, select)) - { - SET_FLAG_FROM_TEST(bp->f1, select, SELECT); + bp = lt->def; + for (w = 0; w < lt->pntsw; w++) { + for (v = 0; v < lt->pntsv; v++) { + for (u = 0; u < lt->pntsu; u++) { + if ((bp->hide == 0) && (((bp->f1 & SELECT) == 0) == select)) { + if (lattice_test_bitmap_uvw(lt, selpoints, u + 1, v, w, select) || + lattice_test_bitmap_uvw(lt, selpoints, u - 1, v, w, select) || + lattice_test_bitmap_uvw(lt, selpoints, u, v + 1, w, select) || + lattice_test_bitmap_uvw(lt, selpoints, u, v - 1, w, select) || + lattice_test_bitmap_uvw(lt, selpoints, u, v, w + 1, select) || + lattice_test_bitmap_uvw(lt, selpoints, u, v, w - 1, select)) + { + SET_FLAG_FROM_TEST(bp->f1, select, SELECT); + } } + bp++; } - bp++; } } - } - MEM_freeN(selpoints); + MEM_freeN(selpoints); - DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); - return OPERATOR_FINISHED; + changed = true; + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + } + MEM_freeN(objects); + + return changed ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } static int lattice_select_more_exec(bContext *C, wmOperator *UNUSED(op)) |