diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-01-07 12:54:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-01-07 12:57:03 +0300 |
commit | eed28a1db8b8145a6751ebfe0df40f345d7244be (patch) | |
tree | bf30bc6d8e75690e840e21b1a2fbc35cd06d6ecc /source/blender | |
parent | 9e3ae79a5435f0d201b973667bba53d1da0d8c90 (diff) |
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).
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 5 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 19 | ||||
-rw-r--r-- | source/blender/editors/object/object_lattice.c | 30 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_enum_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 16 |
5 files changed, 47 insertions, 25 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index f072e707d00..5436ef4b06b 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -129,8 +129,9 @@ bool BMBVH_EdgeVisible(struct BMBVHTree *tree, struct BMEdge *e, struct ARegion *ar, struct View3D *v3d, struct Object *obedit); /* editmesh_select.c */ -void EDBM_select_mirrored(struct BMEditMesh *em, bool extend, - int *r_totmirr, int *r_totfail); +void EDBM_select_mirrored( + struct BMEditMesh *em, const int axis, const bool extend, + int *r_totmirr, int *r_totfail); void EDBM_automerge(struct Scene *scene, struct Object *ob, bool update, const char hflag); bool EDBM_backbuf_border_init(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index f46b208fdb3..a770fc26cba 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -74,8 +74,9 @@ /* ****************************** MIRROR **************** */ -void EDBM_select_mirrored(BMEditMesh *em, bool extend, - int *r_totmirr, int *r_totfail) +void EDBM_select_mirrored( + BMEditMesh *em, const int axis, const bool extend, + int *r_totmirr, int *r_totfail) { Mesh *me = (Mesh *)em->ob->data; BMesh *bm = em->bm; @@ -106,7 +107,7 @@ void EDBM_select_mirrored(BMEditMesh *em, bool extend, } } - EDBM_verts_mirror_cache_begin(em, 0, true, true, use_topology); + EDBM_verts_mirror_cache_begin(em, axis, true, true, use_topology); if (!extend) EDBM_flag_disable_all(em, BM_ELEM_SELECT); @@ -3019,12 +3020,18 @@ static int edbm_select_mirror_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); - bool extend = RNA_boolean_get(op->ptr, "extend"); + const int axis_flag = RNA_enum_get(op->ptr, "axis"); + const bool extend = RNA_boolean_get(op->ptr, "extend"); if (em->bm->totvert && em->bm->totvertsel) { int totmirr, totfail; - EDBM_select_mirrored(em, extend, &totmirr, &totfail); + for (int axis = 0; axis < 3; axis++) { + if ((1 << axis) & axis_flag) { + EDBM_select_mirrored(em, axis, extend, &totmirr, &totfail); + } + } + if (totmirr) { EDBM_selectmode_flush(em); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); @@ -3051,6 +3058,8 @@ void MESH_OT_select_mirror(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ + RNA_def_enum_flag(ot->srna, "axis", rna_enum_axis_flag_xyz_items, (1 << 0), "Axis", ""); + RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the existing selection"); } 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"); } diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 0efdb3d839a..dd646ec12de 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -116,6 +116,8 @@ extern EnumPropertyItem rna_enum_gpencil_sculpt_brush_items[]; extern EnumPropertyItem rna_enum_axis_xy_items[]; extern EnumPropertyItem rna_enum_axis_xyz_items[]; +extern EnumPropertyItem rna_enum_axis_flag_xyz_items[]; + extern EnumPropertyItem rna_enum_symmetrize_direction_items[]; extern EnumPropertyItem rna_enum_texture_type_items[]; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 75030b83f80..d0067c81662 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -268,6 +268,13 @@ EnumPropertyItem rna_enum_axis_xyz_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem rna_enum_axis_flag_xyz_items[] = { + {(1 << 0), "X", 0, "X", ""}, + {(1 << 1), "Y", 0, "Y", ""}, + {(1 << 2), "Z", 0, "Z", ""}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "DNA_particle_types.h" @@ -4097,13 +4104,6 @@ static void rna_def_modifier_meshcache(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem prop_flip_axis_flag_items[] = { - {(1 << 0), "X", 0, "X", ""}, - {(1 << 1), "Y", 0, "Y", ""}, - {(1 << 2), "Z", 0, "Z", ""}, - {0, NULL, 0, NULL, NULL} - }; - StructRNA *srna; PropertyRNA *prop; @@ -4168,7 +4168,7 @@ static void rna_def_modifier_meshcache(BlenderRNA *brna) prop = RNA_def_property(srna, "flip_axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "flip_axis"); - RNA_def_property_enum_items(prop, prop_flip_axis_flag_items); + RNA_def_property_enum_items(prop, rna_enum_axis_flag_xyz_items); RNA_def_property_flag(prop, PROP_ENUM_FLAG); RNA_def_property_ui_text(prop, "Flip Axis", ""); RNA_def_property_update(prop, 0, "rna_Modifier_update"); |