static int lattice_select_mirror_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt; const bool extend = RNA_boolean_get(op->ptr, "extend"); const int axis = RNA_enum_get(op->ptr, "axis"); bool flip_uvw[3] = {false}; int tot, i; BPoint *bp; BLI_bitmap *selpoints; tot = lt->pntsu * lt->pntsv * lt->pntsw; flip_uvw[axis] = true; if (!extend) { lt->actbp = LT_ACTBP_NONE; } /* store "original" selection */ selpoints = BLI_BITMAP_NEW(tot, __func__); BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false); /* actual (de)selection */ for (i = 0; i < tot; i++) { const int i_flip = BKE_lattice_index_flip(lt, i, flip_uvw[0], flip_uvw[1], flip_uvw[2]); bp = <->def[i]; if (!bp->hide) { if (BLI_BITMAP_TEST(selpoints, i_flip)) { bp->f1 |= SELECT; } else { if (!extend) { bp->f1 &= ~SELECT; } } } } MEM_freeN(selpoints); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; }
static void ed_lattice_select_mirrored(Lattice *lt, const int axis, const bool extend) { const int tot = lt->pntsu * lt->pntsv * lt->pntsw; int i; BPoint *bp; BLI_bitmap *selpoints; bool flip_uvw[3] = {false}; flip_uvw[axis] = true; /* we could flip this too */ if (!extend) { lt->actbp = LT_ACTBP_NONE; } /* store "original" selection */ selpoints = BLI_BITMAP_NEW(tot, __func__); BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false); /* actual (de)selection */ for (i = 0; i < tot; i++) { const int i_flip = BKE_lattice_index_flip(lt, i, flip_uvw[0], flip_uvw[1], flip_uvw[2]); bp = <->def[i]; if (!bp->hide) { if (BLI_BITMAP_TEST(selpoints, i_flip)) { bp->f1 |= SELECT; } else { if (!extend) { bp->f1 &= ~SELECT; } } } } MEM_freeN(selpoints); }