diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-20 00:27:30 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-20 00:27:30 +0400 |
commit | 0fd176e03d0f6b0c6e4211c0a29eafa8309c4b8b (patch) | |
tree | 6b8f920d109f75a1e91259a497b05f2f39920805 /source/blender/editors/mesh | |
parent | d8a70df8cc1e82878ff3069d7794367ebf20c6fb (diff) |
moved select interior faces into a C function (was python)
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/bmesh_select.c | 32 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_tools.c | 31 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 1 |
4 files changed, 65 insertions, 0 deletions
diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c index b0440eeb14f..38daf3c0d22 100644 --- a/source/blender/editors/mesh/bmesh_select.c +++ b/source/blender/editors/mesh/bmesh_select.c @@ -1694,6 +1694,38 @@ void EDBM_select_swap(BMEditMesh *em) /* exported for UV */ // if (EM_texFaceCheck()) } +int EDBM_select_interior_faces(struct BMEditMesh *em) +{ + BMesh *bm = em->bm; + BMIter iter; + BMIter eiter; + BMFace *efa; + BMEdge *eed; + int ok; + int change = FALSE; + + BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { + if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) + continue; + + + ok = TRUE; + BM_ITER(eed, &eiter, bm, BM_EDGES_OF_FACE, efa) { + if (BM_edge_face_count(eed) < 3) { + ok = FALSE; + break; + } + } + + if (ok) { + BM_elem_select_set(bm, efa, TRUE); + change = TRUE; + } + } + + return change; +} + static void linked_limit_default(bContext *C, wmOperator *op) { if (!RNA_struct_property_is_set(op->ptr, "limit")) { diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 63834815f42..cffc001b8d2 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -680,6 +680,37 @@ void MESH_OT_select_all(wmOperatorType *ot) WM_operator_properties_select_all(ot); } +static int mesh_faces_select_interior_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Object *obedit = CTX_data_edit_object(C); + BMEditMesh *em = ((Mesh *)obedit->data)->edit_btmesh; + + if (EDBM_select_interior_faces(em)) { + WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } + +} + +void MESH_OT_select_interior_faces(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Interior Faces"; + ot->idname = "MESH_OT_select_interior_faces"; + ot->description = "Select faces where all edges have more than 2 face users"; + + /* api callbacks */ + ot->exec = mesh_faces_select_interior_exec; + ot->poll = ED_operator_editmesh; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + /* *************** add-click-mesh (extrude) operator ************** */ /* in trunk see: 'editmesh_add.c' */ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index ec92b78c2c4..58ad32fad4d 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -200,6 +200,7 @@ void MESH_OT_knife_cut(struct wmOperatorType *ot); /* ******************* bmesh_select.c */ void MESH_OT_loop_select(struct wmOperatorType *ot); void MESH_OT_select_all(struct wmOperatorType *ot); +void MESH_OT_select_interior_faces(struct wmOperatorType *ot); void MESH_OT_bmesh_test(struct wmOperatorType *ot); void MESH_OT_select_more(struct wmOperatorType *ot); void MESH_OT_select_less(struct wmOperatorType *ot); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index d26fc5c6492..4bc500fcdab 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -60,6 +60,7 @@ void ED_operatortypes_mesh(void) { WM_operatortype_append(MESH_OT_select_all); + WM_operatortype_append(MESH_OT_select_interior_faces); WM_operatortype_append(MESH_OT_select_more); WM_operatortype_append(MESH_OT_select_less); WM_operatortype_append(MESH_OT_select_non_manifold); |