diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-16 20:11:50 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-16 20:11:50 +0400 |
commit | 8a4a034325b856c56de992e58ed1aef287961e73 (patch) | |
tree | 3769005eaf2909ceae30c621b2837956e7d1a68c /source/blender | |
parent | a38dbb5eac43ea980225b21f9d9713b8b28d9781 (diff) |
patch [#34634] Select vertices without a group
from Kevin Mackay (yakca)
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 1 | ||||
-rw-r--r-- | source/blender/editors/mesh/editface.c | 31 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 54 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_lattice.c | 53 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 1 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 1 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 34 |
11 files changed, 179 insertions, 0 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 75c66779d6d..e704b8f0bf3 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -193,6 +193,7 @@ void paintface_hide(struct Object *ob, const int unselected); void paintface_reveal(struct Object *ob); void paintvert_deselect_all_visible(struct Object *ob, int action, short flush_flags); +void paintvert_select_ungrouped(struct Object *ob, short extend, short flush_flags); void paintvert_flush_flags(struct Object *ob); /* mirrtopo */ diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index ec146380111..260d01d726a 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -712,6 +712,37 @@ void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags) } } +void paintvert_select_ungrouped(Object *ob, short extend, short flush_flags) +{ + Mesh *me = BKE_mesh_from_object(ob); + MVert *mv; + MDeformVert *dv; + int a, tot; + + if (me == NULL || me->dvert == NULL) { + return; + } + + if (!extend) { + paintvert_deselect_all_visible(ob, SEL_DESELECT, FALSE); + } + + dv = me->dvert; + tot = me->totvert; + + for (a = 0, mv = me->mvert; a < tot; a++, mv++, dv++) { + if ((mv->flag & ME_HIDE) == 0) { + if (dv->dw == NULL) { + /* if null weight then not grouped */ + mv->flag |= SELECT; + } + } + } + + if (flush_flags) { + paintvert_flush_flags(ob); + } +} /* ********************* MESH VERTEX MIRR TOPO LOOKUP *************** */ /* note, this is not the best place for the function to be but moved diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index ccf77b70ea0..cf776587d1f 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -64,6 +64,7 @@ #include "DNA_scene_types.h" #include "DNA_object_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "mesh_intern.h" @@ -2956,6 +2957,59 @@ void MESH_OT_select_random(wmOperatorType *ot) RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); } +static int edbm_select_ungrouped_exec(bContext *C, wmOperator *op) +{ + Object *obedit = CTX_data_edit_object(C); + BMEditMesh *em = BMEdit_FromObject(obedit); + BMVert *eve; + BMIter iter; + + if (!em->selectmode == SCE_SELECT_VERTEX) { + BKE_report(op->reports, RPT_ERROR, "Does not work out of vertex selection mode"); + return OPERATOR_CANCELLED; + } + + if (obedit->defbase.first == NULL) { + BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object"); + return OPERATOR_CANCELLED; + } + + if (!RNA_boolean_get(op->ptr, "extend")) { + EDBM_flag_disable_all(em, BM_ELEM_SELECT); + } + + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { + if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { + MDeformVert *dv = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); + /* no dv or dv set with no weight */ + if (dv == NULL || (dv && dv->dw == NULL)) { + BM_vert_select_set(em->bm, eve, true); + } + } + } + + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + + return OPERATOR_FINISHED; +} + +void MESH_OT_select_ungrouped(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Ungrouped"; + ot->idname = "MESH_OT_select_ungrouped"; + ot->description = "Select vertices without a group"; + + /* api callbacks */ + ot->exec = edbm_select_ungrouped_exec; + ot->poll = ED_operator_editmesh; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); +} + static int edbm_select_next_loop_exec(bContext *C, wmOperator *UNUSED(op)) { Object *obedit = CTX_data_edit_object(C); diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index f2b11877a70..e12d128eb76 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -128,6 +128,7 @@ void MESH_OT_select_shortest_path(struct wmOperatorType *ot); void MESH_OT_select_similar(struct wmOperatorType *ot); void MESH_OT_select_mode(struct wmOperatorType *ot); void MESH_OT_select_random(struct wmOperatorType *ot); +void MESH_OT_select_ungrouped(struct wmOperatorType *ot); void MESH_OT_loop_multi_select(struct wmOperatorType *ot); void MESH_OT_mark_seam(struct wmOperatorType *ot); void MESH_OT_mark_sharp(struct wmOperatorType *ot); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 50c1b55ac1c..4c6c9ba0757 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -59,6 +59,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_select_linked); WM_operatortype_append(MESH_OT_select_linked_pick); WM_operatortype_append(MESH_OT_select_random); + WM_operatortype_append(MESH_OT_select_ungrouped); WM_operatortype_append(MESH_OT_hide); WM_operatortype_append(MESH_OT_reveal); WM_operatortype_append(MESH_OT_select_face_by_sides); diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index a302aa65fd0..163a869613b 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -138,6 +138,7 @@ void OBJECT_OT_hook_recenter(struct wmOperatorType *ot); /* object_lattice.c */ void LATTICE_OT_select_all(struct wmOperatorType *ot); +void LATTICE_OT_select_ungrouped(struct wmOperatorType *ot); void LATTICE_OT_make_regular(struct wmOperatorType *ot); void LATTICE_OT_flip(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index c9eae776ac7..053f1ffabd0 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -53,6 +53,7 @@ #include "BKE_key.h" #include "BKE_lattice.h" #include "BKE_deform.h" +#include "BKE_report.h" #include "ED_lattice.h" #include "ED_object.h" @@ -255,6 +256,58 @@ void LATTICE_OT_select_all(wmOperatorType *ot) WM_operator_properties_select_all(ot); } +/************************** Select Ungrouped Verts Operator *************************/ + +static int lattice_select_ungrouped_exec(bContext *C, wmOperator *op) +{ + Object *obedit = CTX_data_edit_object(C); + Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt; + MDeformVert *dv; + BPoint *bp; + int a, tot; + + if (obedit->defbase.first == NULL || lt->dvert == NULL) { + BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object"); + return OPERATOR_CANCELLED; + } + + if (!RNA_boolean_get(op->ptr, "extend")) { + ED_setflagsLatt(obedit, 0); + } + + dv = lt->dvert; + tot = lt->pntsu * lt->pntsv * lt->pntsw; + + for (a = 0, bp = lt->def; a < tot; a++, bp++, dv++) { + if (bp->hide == 0) { + if (dv->dw == NULL) { + bp->f1 |= SELECT; + } + } + } + + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + + return OPERATOR_FINISHED; +} + +void LATTICE_OT_select_ungrouped(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Ungrouped"; + ot->idname = "LATTICE_OT_select_ungrouped"; + ot->description = "Select vertices without a group"; + + /* api callbacks */ + ot->exec = lattice_select_ungrouped_exec; + ot->poll = ED_operator_editlattice; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); +} + /************************** Make Regular Operator *************************/ static int make_regular_poll(bContext *C) diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index a774eb7b5b8..594dfd6e271 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -211,6 +211,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_shape_key_move); WM_operatortype_append(LATTICE_OT_select_all); + WM_operatortype_append(LATTICE_OT_select_ungrouped); WM_operatortype_append(LATTICE_OT_make_regular); WM_operatortype_append(LATTICE_OT_flip); diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 2a794c8c5cf..9377e4d43e3 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -192,6 +192,7 @@ void PAINT_OT_face_select_hide(struct wmOperatorType *ot); void PAINT_OT_face_select_reveal(struct wmOperatorType *ot); void PAINT_OT_vert_select_all(struct wmOperatorType *ot); +void PAINT_OT_vert_select_ungrouped(struct wmOperatorType *ot); int vert_paint_poll(struct bContext *C); int mask_paint_poll(struct bContext *C); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 79822a0bd48..87cf79c540a 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -485,6 +485,7 @@ void ED_operatortypes_paint(void) /* vertex selection */ WM_operatortype_append(PAINT_OT_vert_select_all); + WM_operatortype_append(PAINT_OT_vert_select_ungrouped); /* vertex */ WM_operatortype_append(PAINT_OT_vertex_paint_toggle); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 19c061996e7..5e88c7b5730 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -47,6 +47,7 @@ #include "BKE_context.h" #include "BKE_DerivedMesh.h" #include "BKE_paint.h" +#include "BKE_report.h" #include "RNA_access.h" #include "RNA_define.h" @@ -484,6 +485,39 @@ void PAINT_OT_vert_select_all(wmOperatorType *ot) WM_operator_properties_select_all(ot); } + +static int vert_select_ungrouped_exec(bContext *C, wmOperator *op) +{ + Object *ob = CTX_data_active_object(C); + Mesh *me = ob->data; + + if ((ob->defbase.first == NULL) || (me->dvert == NULL)) { + BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object"); + return OPERATOR_CANCELLED; + } + + paintvert_select_ungrouped(ob, RNA_boolean_get(op->ptr, "extend"), TRUE); + ED_region_tag_redraw(CTX_wm_region(C)); + return OPERATOR_FINISHED; +} + +void PAINT_OT_vert_select_ungrouped(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Ungrouped"; + ot->idname = "PAINT_OT_vert_select_ungrouped"; + ot->description = "Select vertices without a group"; + + /* api callbacks */ + ot->exec = vert_select_ungrouped_exec; + ot->poll = vert_paint_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); +} + static int face_select_hide_exec(bContext *C, wmOperator *op) { const int unselected = RNA_boolean_get(op->ptr, "unselected"); |