From eed28a1db8b8145a6751ebfe0df40f345d7244be Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 7 Jan 2016 20:54:17 +1100 Subject: Select mirror multiple axis support Previously you could only select mirror on X axis, now support mirroring on multiple axis as well as more than one (for mesh and lattice data). --- source/blender/editors/object/object_lattice.c | 30 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'source/blender/editors/object') diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 41bb4325fbd..5724e542f33 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -246,21 +246,17 @@ void LATTICE_OT_select_random(wmOperatorType *ot) /* -------------------------------------------------------------------- */ /* Select Mirror Operator */ -static int lattice_select_mirror_exec(bContext *C, wmOperator *op) +static void ed_lattice_select_mirrored(Lattice *lt, const int axis, const bool extend) { - 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; + const int tot = lt->pntsu * lt->pntsv * lt->pntsw; + int i; BPoint *bp; BLI_bitmap *selpoints; - tot = lt->pntsu * lt->pntsv * lt->pntsw; - + bool flip_uvw[3] = {false}; flip_uvw[axis] = true; + /* we could flip this too */ if (!extend) { lt->actbp = LT_ACTBP_NONE; } @@ -287,6 +283,20 @@ static int lattice_select_mirror_exec(bContext *C, wmOperator *op) MEM_freeN(selpoints); +} + +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 int axis_flag = RNA_enum_get(op->ptr, "axis"); + const bool extend = RNA_boolean_get(op->ptr, "extend"); + + for (int axis = 0; axis < 3; axis++) { + if ((1 << axis) & axis_flag) { + ed_lattice_select_mirrored(lt, axis, extend); + } + } WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); @@ -308,7 +318,7 @@ void LATTICE_OT_select_mirror(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - RNA_def_enum(ot->srna, "axis", rna_enum_axis_xyz_items, 0, "Axis", ""); + RNA_def_enum_flag(ot->srna, "axis", rna_enum_axis_flag_xyz_items, (1 << 0), "Axis", ""); RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); } -- cgit v1.2.3