diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-03-14 09:25:23 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-03-14 09:54:45 +0300 |
commit | 8803c5ca5d8a99d97529ce2c170a268b52335997 (patch) | |
tree | fe4cda3fd4024b7e49b96785fb758e2851993e7f /source/blender/editors | |
parent | c1694540c33d9c180f295eb3c81d2759a1d82d82 (diff) |
Cleanup: use sections for editmesh tools/select
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 438 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 733 |
2 files changed, 820 insertions, 351 deletions
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 7d20f7a5665..c84ba93ec0d 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -73,7 +73,9 @@ /* use bmesh operator flags for a few operators */ #define BMO_ELE_TAG 1 -/* ****************************** MIRROR **************** */ +/* -------------------------------------------------------------------- */ +/** \name Select Mirror + * \{ */ void EDBM_select_mirrored( BMEditMesh *em, const int axis, const bool extend, @@ -166,21 +168,34 @@ void EDBM_select_mirrored( *r_totfail = totfail; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Auto-Merge + * + * Used after transform operations. + * \{ */ + void EDBM_automerge(Scene *scene, Object *obedit, bool update, const char hflag) { bool ok; BMEditMesh *em = BKE_editmesh_from_object(obedit); - ok = BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS, - "automerge verts=%hv dist=%f", - hflag, scene->toolsettings->doublimit); + ok = BMO_op_callf( + em->bm, BMO_FLAG_DEFAULTS, + "automerge verts=%hv dist=%f", + hflag, scene->toolsettings->doublimit); if (LIKELY(ok) && update) { EDBM_update_generic(em, true, true); } } -/* ****************************** SELECTION ROUTINES **************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Back-Buffer OpenGL Selection + * \{ */ unsigned int bm_solidoffs = 0, bm_wireoffs = 0, bm_vertoffs = 0; /* set in drawobject.c ... for colorindices */ @@ -199,21 +214,21 @@ bool EDBM_backbuf_border_init(ViewContext *vc, short xmin, short ymin, short xma struct ImBuf *buf; unsigned int *dr; int a; - + if (vc->obedit == NULL || !V3D_IS_ZBUF(vc->v3d)) { return false; } - + buf = ED_view3d_backbuf_read(vc, xmin, ymin, xmax, ymax); if ((buf == NULL) || (bm_vertoffs == 0)) { return false; } dr = buf->rect; - + /* build selection lookup */ selbuf = edbm_backbuf_alloc(bm_vertoffs + 1); - + a = (xmax - xmin + 1) * (ymax - ymin + 1); while (a--) { if (*dr > 0 && *dr <= bm_vertoffs) { @@ -263,9 +278,9 @@ static void edbm_mask_lasso_px_cb(int x, int x_end, int y, void *user_data) /* mcords is a polygon mask * - grab backbuffer, - * - draw with black in backbuffer, + * - draw with black in backbuffer, * - grab again and compare - * returns 'OK' + * returns 'OK' */ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax) { @@ -273,7 +288,7 @@ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short struct ImBuf *buf; int a; struct LassoMaskData lasso_mask_data; - + /* method in use for face selecting too */ if (vc->obedit == NULL) { if (!BKE_paint_select_elem_test(vc->obact)) { @@ -302,7 +317,7 @@ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short /* build selection lookup */ selbuf = edbm_backbuf_alloc(bm_vertoffs + 1); - + a = (xmax - xmin + 1) * (ymax - ymin + 1); while (a--) { if (*dr > 0 && *dr <= bm_vertoffs && *dr_mask == true) { @@ -323,7 +338,7 @@ bool EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads) unsigned int *dr; short xmin, ymin, xmax, ymax, xc, yc; int radsq; - + /* method in use for face selecting too */ if (vc->obedit == NULL) { if (!BKE_paint_select_elem_test(vc->obact)) { @@ -342,7 +357,7 @@ bool EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads) } dr = buf->rect; - + /* build selection lookup */ selbuf = edbm_backbuf_alloc(bm_vertoffs + 1); radsq = rads * rads; @@ -358,12 +373,12 @@ bool EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads) IMB_freeImBuf(buf); return true; - + } +/** \} */ /* -------------------------------------------------------------------- */ - /** \name Find Nearest Vert/Edge/Face * * \note Screen-space manhatten distances are used here, @@ -445,14 +460,14 @@ BMVert *EDBM_vert_find_nearest_ex( float dist_test; unsigned int index; BMVert *eve; - + /* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */ ED_view3d_backbuf_validate(vc); index = ED_view3d_backbuf_sample_rect( vc, vc->mval, dist_px, bm_wireoffs, 0xFFFFFF, &dist_test); eve = index ? BM_vert_at_index_find_or_table(bm, index - 1) : NULL; - + if (eve) { if (dist_test < *r_dist) { *r_dist = dist_test; @@ -811,7 +826,7 @@ BMFace *EDBM_face_find_nearest_ex( index = ED_view3d_backbuf_sample(vc, vc->mval[0], vc->mval[1]); efa = index ? BM_face_at_index_find_or_table(bm, index - 1) : NULL; - + if (r_efa_zbuf) { *r_efa_zbuf = efa; } @@ -889,8 +904,8 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist) #undef FIND_NEAR_CYCLE_THRESHOLD_MIN -/* best distance based on screen coords. - * use em->selectmode to define how to use +/* best distance based on screen coords. + * use em->selectmode to define how to use * selected vertices and edges get disadvantage * return 1 if found one */ @@ -906,7 +921,7 @@ static int unified_findnearest(ViewContext *vc, BMVert **r_eve, BMEdge **r_eed, float dist = dist_init; BMFace *efa_zbuf = NULL; BMEdge *eed_zbuf = NULL; - + BMVert *eve = NULL; BMEdge *eed = NULL; BMFace *efa = NULL; @@ -968,8 +983,10 @@ static int unified_findnearest(ViewContext *vc, BMVert **r_eve, BMEdge **r_eed, /** \} */ +/* -------------------------------------------------------------------- */ +/** \name Select Similar (Vert/Edge/Face) Operator + * \{ */ -/* **************** SIMILAR "group" SELECTS. FACE, EDGE AND VERTEX ************** */ static const EnumPropertyItem prop_similar_compare_types[] = { {SIM_CMP_EQ, "EQUAL", 0, "Equal", ""}, {SIM_CMP_GT, "GREATER", 0, "Greater", ""}, @@ -1046,7 +1063,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) EDBM_update_generic(em, false, false); return OPERATOR_FINISHED; -} +} /* ***************************************************** */ @@ -1152,8 +1169,9 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op) else return similar_face_select_exec(C, op); } -static const EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), - bool *r_free) +static const EnumPropertyItem *select_similar_type_itemf( + bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), + bool *r_free) { Object *obedit; @@ -1205,15 +1223,15 @@ void MESH_OT_select_similar(wmOperatorType *ot) ot->name = "Select Similar"; ot->idname = "MESH_OT_select_similar"; ot->description = "Select similar vertices, edges or faces by property types"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = edbm_select_similar_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = ot->prop = RNA_def_enum(ot->srna, "type", prop_similar_types, SIMVERT_NORMAL, "Type", ""); RNA_def_enum_funcs(prop, select_similar_type_itemf); @@ -1223,9 +1241,11 @@ void MESH_OT_select_similar(wmOperatorType *ot) RNA_def_float(ot->srna, "threshold", 0.0f, 0.0f, 1.0f, "Threshold", "", 0.0f, 1.0f); } +/** \} */ /* -------------------------------------------------------------------- */ -/* Select Similar Regions */ +/** \name Select Similar Region Operator + * \{ */ static int edbm_select_similar_region_exec(bContext *C, wmOperator *op) { @@ -1246,9 +1266,10 @@ static int edbm_select_similar_region_exec(bContext *C, wmOperator *op) } groups_array = MEM_mallocN(sizeof(*groups_array) * bm->totfacesel, __func__); - group_tot = BM_mesh_calc_face_groups(bm, groups_array, &group_index, - NULL, NULL, - BM_ELEM_SELECT, BM_VERT); + group_tot = BM_mesh_calc_face_groups( + bm, groups_array, &group_index, + NULL, NULL, + BM_ELEM_SELECT, BM_VERT); BM_mesh_elem_table_ensure(bm, BM_FACE); @@ -1313,8 +1334,11 @@ void MESH_OT_select_similar_region(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ -/* **************** Mode Select *************** */ +/* -------------------------------------------------------------------- */ +/** \name Select Mode Vert/Edge/Face Operator + * \{ */ static int edbm_select_mode_exec(bContext *C, wmOperator *op) { @@ -1385,12 +1409,15 @@ void MESH_OT_select_mode(wmOperatorType *ot) RNA_def_enum(ot->srna, "action", actions_items, 2, "Action", "Selection action to execute"); } -/* ***************************************************** */ +/** \} */ -/* **************** LOOP SELECTS *************** */ +/* -------------------------------------------------------------------- */ +/** \name Select Loop (Non Modal) Operator + * \{ */ -static void walker_select_count(BMEditMesh *em, int walkercode, void *start, const bool select, const bool select_mix, - int *r_totsel, int *r_totunsel) +static void walker_select_count( + BMEditMesh *em, int walkercode, void *start, const bool select, const bool select_mix, + int *r_totsel, int *r_totunsel) { BMesh *bm = em->bm; BMElem *ele; @@ -1445,7 +1472,7 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op) BMEdge **edarray; int edindex; const bool is_ring = RNA_boolean_get(op->ptr, "ring"); - + BMIter iter; int totedgesel = 0; @@ -1454,17 +1481,17 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op) totedgesel++; } } - + edarray = MEM_mallocN(sizeof(BMEdge *) * totedgesel, "edge array"); edindex = 0; - + BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { edarray[edindex] = eed; edindex++; } } - + if (is_ring) { for (edindex = 0; edindex < totedgesel; edindex += 1) { eed = edarray[edindex]; @@ -1481,7 +1508,7 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op) } MEM_freeN(edarray); // if (EM_texFaceCheck()) - + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; @@ -1493,23 +1520,23 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) ot->name = "Multi Select Loops"; ot->idname = "MESH_OT_loop_multi_select"; ot->description = "Select a loop of connected edges by connection type"; - + /* api callbacks */ ot->exec = edbm_loop_multiselect_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "ring", 0, "Ring", ""); } - -/* ***************** MAIN MOUSE SELECTION ************** */ - +/** \} */ -/* ***************** loop select (non modal) ************** */ +/* -------------------------------------------------------------------- */ +/** \name Select Loop (Cursor Pick) Operator + * \{ */ static void mouse_mesh_loop_face(BMEditMesh *em, BMEdge *eed, bool select, bool select_clear) { @@ -1564,7 +1591,6 @@ static void mouse_mesh_loop_edge(BMEditMesh *em, BMEdge *eed, bool select, bool } } - static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle, bool ring) { ViewContext vc; @@ -1641,11 +1667,15 @@ static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool de /* We can't be sure this has already been set... */ ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); - if (ED_view3d_project_float_object(vc.ar, eed->v1->co, v1_co, V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_object( + vc.ar, eed->v1->co, v1_co, V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) + { length_1 = len_squared_v2v2(mvalf, v1_co); } - if (ED_view3d_project_float_object(vc.ar, eed->v2->co, v2_co, V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_object( + vc.ar, eed->v2->co, v2_co, V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) + { length_2 = len_squared_v2v2(mvalf, v2_co); } #if 0 @@ -1672,7 +1702,9 @@ static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool de float co[2], tdist; BM_face_calc_center_mean(f, cent); - if (ED_view3d_project_float_object(vc.ar, cent, co, V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_object( + vc.ar, cent, co, V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) + { tdist = len_squared_v2v2(mvalf, co); if (tdist < best_dist) { /* printf("Best face: %p (%f)\n", f, tdist);*/ @@ -1696,14 +1728,15 @@ static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool de static int edbm_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - + view3d_operator_needs_opengl(C); - - if (mouse_mesh_loop(C, event->mval, - RNA_boolean_get(op->ptr, "extend"), - RNA_boolean_get(op->ptr, "deselect"), - RNA_boolean_get(op->ptr, "toggle"), - RNA_boolean_get(op->ptr, "ring"))) + + if (mouse_mesh_loop( + C, event->mval, + RNA_boolean_get(op->ptr, "extend"), + RNA_boolean_get(op->ptr, "deselect"), + RNA_boolean_get(op->ptr, "toggle"), + RNA_boolean_get(op->ptr, "ring"))) { return OPERATOR_FINISHED; } @@ -1718,14 +1751,14 @@ void MESH_OT_loop_select(wmOperatorType *ot) ot->name = "Loop Select"; ot->idname = "MESH_OT_loop_select"; ot->description = "Select a loop of connected edges"; - + /* api callbacks */ ot->invoke = edbm_select_loop_invoke; ot->poll = ED_operator_editmesh_region_view3d; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "Extend the selection"); RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Remove from the selection"); @@ -1739,11 +1772,11 @@ void MESH_OT_edgering_select(wmOperatorType *ot) ot->name = "Edge Ring Select"; ot->idname = "MESH_OT_edgering_select"; ot->description = "Select an edge ring"; - + /* callbacks */ ot->invoke = edbm_select_loop_invoke; ot->poll = ED_operator_editmesh_region_view3d; - + /* flags */ ot->flag = OPTYPE_UNDO; @@ -1753,7 +1786,12 @@ void MESH_OT_edgering_select(wmOperatorType *ot) RNA_def_boolean(ot->srna, "ring", 1, "Select Ring", "Select ring"); } -/* ******************** (de)select all operator **************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name (De)Select All Operator + * \{ */ + static int edbm_select_all_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -1798,6 +1836,12 @@ void MESH_OT_select_all(wmOperatorType *ot) WM_operator_properties_select_all(ot); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Interior Faces Operator + * \{ */ + static int edbm_faces_select_interior_exec(bContext *C, wmOperator *UNUSED(op)) { Object *obedit = CTX_data_edit_object(C); @@ -1829,10 +1873,15 @@ void MESH_OT_select_interior_faces(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Picking API + * + * Here actual select happens, + * Gets called via generic mouse select operator. + * \{ */ -/* ************************************************** */ -/* here actual select happens */ -/* gets called via generic mouse select operator */ bool EDBM_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) { ViewContext vc; @@ -1948,6 +1997,12 @@ bool EDBM_select_pick(bContext *C, const int mval[2], bool extend, bool deselect return false; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Mode Utilities + * \{ */ + static void edbm_strip_selections(BMEditMesh *em) { BMEditSelection *ese, *nextese; @@ -1986,11 +2041,11 @@ void EDBM_selectmode_set(BMEditMesh *em) BMEdge *eed; BMFace *efa; BMIter iter; - + em->bm->selectmode = em->selectmode; edbm_strip_selections(em); /* strip BMEditSelections from em->selected that are not relevant to new mode */ - + if (em->bm->totvertsel == 0 && em->bm->totedgesel == 0 && em->bm->totfacesel == 0) @@ -2153,8 +2208,9 @@ void EDBM_selectmode_convert(BMEditMesh *em, const short selectmode_old, const s } /* user facing function, does notification */ -bool EDBM_selectmode_toggle(bContext *C, const short selectmode_new, - const int action, const bool use_extend, const bool use_expand) +bool EDBM_selectmode_toggle( + bContext *C, const short selectmode_new, + const int action, const bool use_extend, const bool use_expand) { ToolSettings *ts = CTX_data_tool_settings(C); Object *obedit = CTX_data_edit_object(C); @@ -2250,9 +2306,10 @@ bool EDBM_selectmode_toggle(bContext *C, const short selectmode_new, * * \return true if the mode is changed. */ -bool EDBM_selectmode_disable(Scene *scene, BMEditMesh *em, - const short selectmode_disable, - const short selectmode_fallback) +bool EDBM_selectmode_disable( + Scene *scene, BMEditMesh *em, + const short selectmode_disable, + const short selectmode_fallback) { /* note essential, but switch out of vertex mode since the * selected regions wont be nicely isolated after flushing */ @@ -2275,6 +2332,12 @@ bool EDBM_selectmode_disable(Scene *scene, BMEditMesh *em, } } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Toggle + * \{ */ + void EDBM_deselect_by_material(BMEditMesh *em, const short index, const bool select) { BMIter iter; @@ -2303,7 +2366,7 @@ void EDBM_select_swap(BMEditMesh *em) /* exported for UV */ BMVert *eve; BMEdge *eed; BMFace *efa; - + if (em->bm->selectmode & SCE_SELECT_VERTEX) { BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) @@ -2326,9 +2389,17 @@ void EDBM_select_swap(BMEditMesh *em) /* exported for UV */ } } -// if (EM_texFaceCheck()) } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Interior Faces + * + * \note This algorithm is limited to single faces and could be improved, see: + * https://blender.stackexchange.com/questions/18916 + * \{ */ + bool EDBM_select_interior_faces(BMEditMesh *em) { BMesh *bm = em->bm; @@ -2361,8 +2432,13 @@ bool EDBM_select_interior_faces(BMEditMesh *em) return changed; } +/** \} */ -/************************ Select Linked Operator *************************/ +/* -------------------------------------------------------------------- */ +/** \name Select Linked Operator + * + * Support delimiting on different edge properties. + * \{ */ /* so we can have last-used default depend on selection mode (rare exception!) */ #define USE_LINKED_SELECT_DEFAULT_HACK @@ -2683,6 +2759,12 @@ void MESH_OT_select_linked(wmOperatorType *ot) #endif } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Linked (Cursor Pick) Operator + * \{ */ + static int edbm_select_linked_pick_exec(bContext *C, wmOperator *op); static void edbm_select_linked_pick_ex(BMEditMesh *em, BMElem *ele, bool sel, int delimit) @@ -2884,15 +2966,15 @@ void MESH_OT_select_linked_pick(wmOperatorType *ot) ot->name = "Select Linked"; ot->idname = "MESH_OT_select_linked_pick"; ot->description = "(De)select all vertices linked to the edge under the mouse cursor"; - + /* api callbacks */ ot->invoke = edbm_select_linked_pick_invoke; ot->exec = edbm_select_linked_pick_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", ""); prop = RNA_def_enum_flag(ot->srna, "delimit", rna_enum_mesh_delimit_mode_items, BMO_DELIM_SEAM, "Delimit", "Delimit selected region"); @@ -2905,6 +2987,11 @@ void MESH_OT_select_linked_pick(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Face by Sides Operator + * \{ */ static int edbm_select_face_by_sides_exec(bContext *C, wmOperator *op) { @@ -2980,6 +3067,11 @@ void MESH_OT_select_face_by_sides(wmOperatorType *ot) RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend the selection"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Loose Operator + * \{ */ static int edbm_select_loose_exec(bContext *C, wmOperator *op) { @@ -3051,6 +3143,11 @@ void MESH_OT_select_loose(wmOperatorType *ot) RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Mirror Operator + * \{ */ static int edbm_select_mirror_exec(bContext *C, wmOperator *op) { @@ -3099,7 +3196,11 @@ void MESH_OT_select_mirror(wmOperatorType *ot) RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the existing selection"); } -/* ******************** **************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select More Operator + * \{ */ static int edbm_select_more_exec(bContext *C, wmOperator *op) { @@ -3123,13 +3224,19 @@ void MESH_OT_select_more(wmOperatorType *ot) /* api callbacks */ ot->exec = edbm_select_more_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "use_face_step", true, "Face Step", "Connected faces (instead of edges)"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select More Operator + * \{ */ + static int edbm_select_less_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -3152,13 +3259,19 @@ void MESH_OT_select_less(wmOperatorType *ot) /* api callbacks */ ot->exec = edbm_select_less_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "use_face_step", true, "Face Step", "Connected faces (instead of edges)"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select N'th Operator + * \{ */ + /** * Check if we're connected to another selected efge. */ @@ -3382,12 +3495,17 @@ void MESH_OT_select_nth(wmOperatorType *ot) void em_setup_viewcontext(bContext *C, ViewContext *vc) { ED_view3d_viewcontext_init(C, vc); - + if (vc->obedit) { vc->em = BKE_editmesh_from_object(vc->obedit); } } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Sharp Edges Operator + * \{ */ static int edbm_select_sharp_edges_exec(bContext *C, wmOperator *op) { @@ -3428,20 +3546,26 @@ void MESH_OT_edges_select_sharp(wmOperatorType *ot) ot->name = "Select Sharp Edges"; ot->description = "Select all sharp-enough edges"; ot->idname = "MESH_OT_edges_select_sharp"; - + /* api callbacks */ ot->exec = edbm_select_sharp_edges_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ prop = RNA_def_float_rotation(ot->srna, "sharpness", 0, NULL, DEG2RADF(0.01f), DEG2RADF(180.0f), "Sharpness", "", DEG2RADF(1.0f), DEG2RADF(180.0f)); RNA_def_property_float_default(prop, DEG2RADF(30.0f)); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Linked Flat Faces Operator + * \{ */ + static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -3509,20 +3633,26 @@ void MESH_OT_faces_select_linked_flat(wmOperatorType *ot) ot->name = "Select Linked Flat Faces"; ot->description = "Select linked faces by angle"; ot->idname = "MESH_OT_faces_select_linked_flat"; - + /* api callbacks */ ot->exec = edbm_select_linked_flat_faces_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ prop = RNA_def_float_rotation(ot->srna, "sharpness", 0, NULL, DEG2RADF(0.01f), DEG2RADF(180.0f), "Sharpness", "", DEG2RADF(1.0f), DEG2RADF(180.0f)); RNA_def_property_float_default(prop, DEG2RADF(1.0f)); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Non-Manifold Operator + * \{ */ + static int edbm_select_non_manifold_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -3544,12 +3674,12 @@ static int edbm_select_non_manifold_exec(bContext *C, wmOperator *op) /* Selects isolated verts, and edges that do not have 2 neighboring * faces */ - + if (em->selectmode == SCE_SELECT_FACE) { BKE_report(op->reports, RPT_ERROR, "Does not work in face selection mode"); return OPERATOR_CANCELLED; } - + if (use_verts) { BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) { @@ -3559,7 +3689,7 @@ static int edbm_select_non_manifold_exec(bContext *C, wmOperator *op) } } } - + if (use_wire || use_boundary || use_multi_face || use_non_contiguous) { BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { @@ -3590,11 +3720,11 @@ void MESH_OT_select_non_manifold(wmOperatorType *ot) ot->name = "Select Non Manifold"; ot->description = "Select all non-manifold vertices or edges"; ot->idname = "MESH_OT_select_non_manifold"; - + /* api callbacks */ ot->exec = edbm_select_non_manifold_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -3614,6 +3744,12 @@ void MESH_OT_select_non_manifold(wmOperatorType *ot) "Vertices connecting multiple face regions"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Random Operator + * \{ */ + static int edbm_select_random_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -3660,9 +3796,9 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op) else { EDBM_deselect_flush(em); } - + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); - + return OPERATOR_FINISHED; } @@ -3679,11 +3815,17 @@ void MESH_OT_select_random(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ WM_operator_properties_select_random(ot); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Ungrouped Operator + * \{ */ + static int edbm_select_ungrouped_poll(bContext *C) { if (ED_operator_editmesh(C)) { @@ -3750,6 +3892,11 @@ void MESH_OT_select_ungrouped(wmOperatorType *ot) RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Axis Operator + * \{ */ /* BMESH_TODO - some way to select on an arbitrary axis */ static int edbm_select_axis_exec(bContext *C, wmOperator *op) @@ -3836,6 +3983,12 @@ void MESH_OT_select_axis(wmOperatorType *ot) RNA_def_float(ot->srna, "threshold", 0.0001f, 0.000001f, 50.0f, "Threshold", "", 0.00001f, 10.0f); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Region to Loop Operator + * \{ */ + static int edbm_region_to_loop_exec(bContext *C, wmOperator *UNUSED(op)) { Object *obedit = CTX_data_edit_object(C); @@ -3849,22 +4002,22 @@ static int edbm_region_to_loop_exec(bContext *C, wmOperator *UNUSED(op)) BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { BMLoop *l1, *l2; BMIter liter1, liter2; - + BM_ITER_ELEM (l1, &liter1, f, BM_LOOPS_OF_FACE) { int tot = 0, totsel = 0; - + BM_ITER_ELEM (l2, &liter2, l1->e, BM_LOOPS_OF_EDGE) { tot++; totsel += BM_elem_flag_test(l2->f, BM_ELEM_SELECT) != 0; } - + if ((tot != totsel && totsel > 0) || (totsel == 1 && tot == 1)) BM_elem_flag_enable(l1->e, BM_ELEM_TAG); } } EDBM_flag_disable_all(em, BM_ELEM_SELECT); - + BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(e, BM_ELEM_TAG)) { BM_edge_select_set(em->bm, e, true); @@ -3899,29 +4052,36 @@ void MESH_OT_region_to_loop(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int loop_find_region(BMLoop *l, int flag, - GSet *visit_face_set, BMFace ***region_out) +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Loop to Region Operator + * \{ */ + +static int loop_find_region( + BMLoop *l, int flag, + GSet *visit_face_set, BMFace ***region_out) { BMFace **region = NULL; BMFace **stack = NULL; BLI_array_declare(region); BLI_array_declare(stack); BMFace *f; - + BLI_array_append(stack, l->f); BLI_gset_insert(visit_face_set, l->f); - + while (BLI_array_count(stack) > 0) { BMIter liter1, liter2; BMLoop *l1, *l2; - + f = BLI_array_pop(stack); BLI_array_append(region, f); - + BM_ITER_ELEM (l1, &liter1, f, BM_LOOPS_OF_FACE) { if (BM_elem_flag_test(l1->e, flag)) continue; - + BM_ITER_ELEM (l2, &liter2, l1->e, BM_LOOPS_OF_EDGE) { /* avoids finding same region twice * (otherwise) the logic works fine without */ @@ -3935,9 +4095,9 @@ static int loop_find_region(BMLoop *l, int flag, } } } - + BLI_array_free(stack); - + *region_out = region; return BLI_array_count(region); } @@ -3947,10 +4107,9 @@ static int verg_radial(const void *va, const void *vb) const BMEdge *e_a = *((const BMEdge **)va); const BMEdge *e_b = *((const BMEdge **)vb); - int a, b; - a = BM_edge_face_count(e_a); - b = BM_edge_face_count(e_b); - + const int a = BM_edge_face_count(e_a); + const int b = BM_edge_face_count(e_b); + if (a > b) return -1; if (a < b) return 1; return 0; @@ -3969,7 +4128,7 @@ static int loop_find_regions(BMEditMesh *em, const bool selbigger) const int edges_len = em->bm->totedgesel; BMEdge *e, **edges; int count = 0, i; - + visit_face_set = BLI_gset_ptr_new_ex(__func__, edges_len); edges = MEM_mallocN(sizeof(*edges) * edges_len, __func__); @@ -3983,21 +4142,21 @@ static int loop_find_regions(BMEditMesh *em, const bool selbigger) BM_elem_flag_disable(e, BM_ELEM_TAG); } } - + /* sort edges by radial cycle length */ qsort(edges, edges_len, sizeof(*edges), verg_radial); - + for (i = 0; i < edges_len; i++) { BMIter liter; BMLoop *l; BMFace **region = NULL, **region_out; int c, tot = 0; - + e = edges[i]; - + if (!BM_elem_flag_test(e, BM_ELEM_TAG)) continue; - + BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) { if (BLI_gset_haskey(visit_face_set, l->f)) continue; @@ -4019,26 +4178,26 @@ static int loop_find_regions(BMEditMesh *em, const bool selbigger) MEM_freeN(region_out); } } - + if (region) { int j; - + for (j = 0; j < tot; j++) { BM_elem_flag_enable(region[j], BM_ELEM_TAG); BM_ITER_ELEM (l, &liter, region[j], BM_LOOPS_OF_FACE) { BM_elem_flag_disable(l->e, BM_ELEM_TAG); } } - + count += tot; - + MEM_freeN(region); } } - + MEM_freeN(edges); BLI_gset_free(visit_face_set, NULL); - + return count; } @@ -4049,25 +4208,23 @@ static int edbm_loop_to_region_exec(bContext *C, wmOperator *op) BMIter iter; BMFace *f; const bool select_bigger = RNA_boolean_get(op->ptr, "select_bigger"); - int a, b; - /* find the set of regions with smallest number of total faces */ BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, false); - a = loop_find_regions(em, select_bigger); - b = loop_find_regions(em, !select_bigger); + const int a = loop_find_regions(em, select_bigger); + const int b = loop_find_regions(em, !select_bigger); BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, false); loop_find_regions(em, ((a <= b) != select_bigger) ? select_bigger : !select_bigger); - + EDBM_flag_disable_all(em, BM_ELEM_SELECT); - + BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(f, BM_ELEM_TAG) && !BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { BM_face_select_set(em->bm, f, true); } } - + EDBM_selectmode_flush(em); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); @@ -4087,9 +4244,8 @@ void MESH_OT_loop_to_region(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "select_bigger", 0, "Select Bigger", "Select bigger regions instead of smaller ones"); } - -/************************ Select Path Operator *************************/ +/** \} */ diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index c979a73e964..84299f12cef 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -84,6 +84,10 @@ #define USE_FACE_CREATE_SEL_EXTEND +/* -------------------------------------------------------------------- */ +/** \name Subdivide Operator + * \{ */ + static int edbm_subdivide_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -93,19 +97,20 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op) const float fractal = RNA_float_get(op->ptr, "fractal") / 2.5f; const float along_normal = RNA_float_get(op->ptr, "fractal_along_normal"); - if (RNA_boolean_get(op->ptr, "quadtri") && + if (RNA_boolean_get(op->ptr, "quadtri") && RNA_enum_get(op->ptr, "quadcorner") == SUBD_CORNER_STRAIGHT_CUT) { RNA_enum_set(op->ptr, "quadcorner", SUBD_CORNER_INNERVERT); } - - BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT, - smooth, SUBD_FALLOFF_LIN, false, - fractal, along_normal, - cuts, - SUBDIV_SELECT_ORIG, RNA_enum_get(op->ptr, "quadcorner"), - RNA_boolean_get(op->ptr, "quadtri"), true, false, - RNA_int_get(op->ptr, "seed")); + + BM_mesh_esubdivide( + em->bm, BM_ELEM_SELECT, + smooth, SUBD_FALLOFF_LIN, false, + fractal, along_normal, + cuts, + SUBDIV_SELECT_ORIG, RNA_enum_get(op->ptr, "quadcorner"), + RNA_boolean_get(op->ptr, "quadtri"), true, false, + RNA_int_get(op->ptr, "seed")); EDBM_update_generic(em, true, true); @@ -154,10 +159,14 @@ void MESH_OT_subdivide(wmOperatorType *ot) RNA_def_int(ot->srna, "seed", 0, 0, INT_MAX, "Random Seed", "Seed for the random number generator", 0, 255); } +/** \} */ + /* -------------------------------------------------------------------- */ -/* Edge Ring Subdiv - * (bridge code shares props) - */ +/** \name Edge Ring Subdivide Operator + * + * Bridge code shares props. + * + * \{ */ struct EdgeRingOpSubdProps { int interp_mode; @@ -219,11 +228,12 @@ static int edbm_subdivide_edge_ring_exec(bContext *C, wmOperator *op) mesh_operator_edgering_props_get(op, &op_props); - if (!EDBM_op_callf(em, op, - "subdivide_edgering edges=%he interp_mode=%i cuts=%i smooth=%f " - "profile_shape=%i profile_shape_factor=%f", - BM_ELEM_SELECT, op_props.interp_mode, op_props.cuts, op_props.smooth, - op_props.profile_shape, op_props.profile_shape_factor)) + if (!EDBM_op_callf( + em, op, + "subdivide_edgering edges=%he interp_mode=%i cuts=%i smooth=%f " + "profile_shape=%i profile_shape_factor=%f", + BM_ELEM_SELECT, op_props.interp_mode, op_props.cuts, op_props.smooth, + op_props.profile_shape, op_props.profile_shape_factor)) { return OPERATOR_CANCELLED; } @@ -251,6 +261,11 @@ void MESH_OT_subdivide_edgering(wmOperatorType *ot) mesh_operator_edgering_props(ot, 1, 10); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Un-Subdivide Operator + * \{ */ static int edbm_unsubdivide_exec(bContext *C, wmOperator *op) { @@ -332,6 +347,11 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em) ED_transform_snap_object_context_destroy(snap_context); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Delete Operator + * \{ */ /* Note, these values must match delete_mesh() event values */ enum { @@ -386,7 +406,7 @@ static int edbm_delete_exec(bContext *C, wmOperator *op) EDBM_flag_disable_all(em, BM_ELEM_SELECT); EDBM_update_generic(em, true, true); - + return OPERATOR_FINISHED; } @@ -405,13 +425,13 @@ void MESH_OT_delete(wmOperatorType *ot) ot->name = "Delete"; ot->description = "Delete selected vertices, edges or faces"; ot->idname = "MESH_OT_delete"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = edbm_delete_exec; - + ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -420,6 +440,11 @@ void MESH_OT_delete(wmOperatorType *ot) "Type", "Method used for deleting mesh data"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Delete Loose Operator + * \{ */ static bool bm_face_is_loose(BMFace *f) { @@ -518,6 +543,11 @@ void MESH_OT_delete_loose(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_faces", false, "Faces", "Remove loose faces"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Collapse Edge Operator + * \{ */ static int edbm_collapse_edge_exec(bContext *C, wmOperator *op) { @@ -547,6 +577,12 @@ void MESH_OT_edge_collapse(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Create Edge/Face Operator + * \{ */ + static bool edbm_add_edge_face__smooth_get(BMesh *bm) { BMEdge *e; @@ -616,8 +652,9 @@ static BMElem *edbm_add_edge_face_exec__tricky_extend_sel(BMesh *bm) (BM_edge_share_face_check(ed_pair[0], ed_pair[1]) == false)) ) { - BMEdge *e_other = BM_edge_exists(BM_edge_other_vert(ed_pair[0], v), - BM_edge_other_vert(ed_pair[1], v)); + BMEdge *e_other = BM_edge_exists( + BM_edge_other_vert(ed_pair[0], v), + BM_edge_other_vert(ed_pair[1], v)); BM_edge_select_set(bm, ed_pair[0], true); BM_edge_select_set(bm, ed_pair[1], true); if (e_other) { @@ -740,13 +777,14 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op) ele_desel = edbm_add_edge_face_exec__tricky_extend_sel(em->bm); #endif - if (!EDBM_op_init(em, &bmop, op, - "contextual_create geom=%hfev mat_nr=%i use_smooth=%b", - BM_ELEM_SELECT, em->mat_nr, use_smooth)) + if (!EDBM_op_init( + em, &bmop, op, + "contextual_create geom=%hfev mat_nr=%i use_smooth=%b", + BM_ELEM_SELECT, em->mat_nr, use_smooth)) { return OPERATOR_CANCELLED; } - + BMO_op_exec(em->bm, &bmop); /* cancel if nothing was done */ @@ -796,16 +834,20 @@ void MESH_OT_edge_face_add(wmOperatorType *ot) ot->name = "Make Edge/Face"; ot->description = "Add an edge or face to selected"; ot->idname = "MESH_OT_edge_face_add"; - + /* api callbacks */ ot->exec = edbm_add_edge_face_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* ************************* SEAMS AND EDGES **************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Mark Edge (Seam) Operator + * \{ */ static int edbm_mark_seam_exec(bContext *C, wmOperator *op) { @@ -817,7 +859,7 @@ static int edbm_mark_seam_exec(bContext *C, wmOperator *op) BMEdge *eed; BMIter iter; const bool clear = RNA_boolean_get(op->ptr, "clear"); - + /* auto-enable seams drawing */ if (clear == 0) { me->drawflag |= ME_DRAWSEAMS; @@ -827,7 +869,7 @@ static int edbm_mark_seam_exec(bContext *C, wmOperator *op) BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_SELECT) || BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) continue; - + BM_elem_flag_disable(eed, BM_ELEM_SEAM); } } @@ -853,18 +895,24 @@ void MESH_OT_mark_seam(wmOperatorType *ot) ot->name = "Mark Seam"; ot->idname = "MESH_OT_mark_seam"; ot->description = "(Un)mark selected edges as a seam"; - + /* api callbacks */ ot->exec = edbm_mark_seam_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + prop = RNA_def_boolean(ot->srna, "clear", 0, "Clear", ""); RNA_def_property_flag(prop, PROP_SKIP_SAVE); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Mark Edge (Sharp) Operator + * \{ */ + static int edbm_mark_sharp_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -907,14 +955,14 @@ void MESH_OT_mark_sharp(wmOperatorType *ot) ot->name = "Mark Sharp"; ot->idname = "MESH_OT_mark_sharp"; ot->description = "(Un)mark selected edges as sharp"; - + /* api callbacks */ ot->exec = edbm_mark_sharp_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + prop = RNA_def_boolean(ot->srna, "clear", false, "Clear", ""); RNA_def_property_flag(prop, PROP_SKIP_SAVE); prop = RNA_def_boolean(ot->srna, "use_verts", false, "Vertices", @@ -958,17 +1006,19 @@ static int edbm_vert_connect_exec(bContext *C, wmOperator *op) } if (is_pair) { - if (!EDBM_op_init(em, &bmop, op, - "connect_vert_pair verts=%eb verts_exclude=%hv faces_exclude=%hf", - verts, verts_len, BM_ELEM_HIDDEN, BM_ELEM_HIDDEN)) + if (!EDBM_op_init( + em, &bmop, op, + "connect_vert_pair verts=%eb verts_exclude=%hv faces_exclude=%hf", + verts, verts_len, BM_ELEM_HIDDEN, BM_ELEM_HIDDEN)) { goto finally; } } else { - if (!EDBM_op_init(em, &bmop, op, - "connect_verts verts=%eb faces_exclude=%hf check_degenerate=%b", - verts, verts_len, BM_ELEM_HIDDEN, check_degenerate)) + if (!EDBM_op_init( + em, &bmop, op, + "connect_verts verts=%eb faces_exclude=%hf check_degenerate=%b", + verts, verts_len, BM_ELEM_HIDDEN, check_degenerate)) { goto finally; } @@ -1005,15 +1055,20 @@ void MESH_OT_vert_connect(wmOperatorType *ot) ot->name = "Vertex Connect"; ot->idname = "MESH_OT_vert_connect"; ot->description = "Connect selected vertices of faces, splitting the face"; - + /* api callbacks */ ot->exec = edbm_vert_connect_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Split Concave Faces Operator + * \{ */ /** * check that endpoints are verts and only have a single selected edge connected. @@ -1318,6 +1373,11 @@ void MESH_OT_vert_connect_concave(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Split Non-Planar Faces Operator + * \{ */ static int edbm_vert_connect_nonplaner_exec(bContext *C, wmOperator *op) { @@ -1362,6 +1422,12 @@ void MESH_OT_vert_connect_nonplanar(wmOperatorType *ot) RNA_def_property_float_default(prop, DEG2RADF(5.0f)); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Make Planar Faces Operator + * \{ */ + static int edbm_face_make_planar_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -1399,6 +1465,11 @@ void MESH_OT_face_make_planar(wmOperatorType *ot) RNA_def_int(ot->srna, "repeat", 1, 1, 10000, "Iterations", "", 1, 200); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Split Edge Operator + * \{ */ static int edbm_edge_split_exec(bContext *C, wmOperator *op) { @@ -1413,7 +1484,7 @@ static int edbm_edge_split_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + if (em->selectmode == SCE_SELECT_FACE) { EDBM_select_flush(em); } @@ -1429,16 +1500,20 @@ void MESH_OT_edge_split(wmOperatorType *ot) ot->name = "Edge Split"; ot->idname = "MESH_OT_edge_split"; ot->description = "Split selected edges so that each neighbor face gets its own copy"; - + /* api callbacks */ ot->exec = edbm_edge_split_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/****************** add duplicate operator ***************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Duplicate Operator + * \{ */ static int edbm_duplicate_exec(bContext *C, wmOperator *op) { @@ -1469,7 +1544,7 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op) } EDBM_update_generic(em, true, true); - + return OPERATOR_FINISHED; } @@ -1478,7 +1553,7 @@ static int edbm_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *UNU WM_cursor_wait(1); edbm_duplicate_exec(C, op); WM_cursor_wait(0); - + return OPERATOR_FINISHED; } @@ -1488,29 +1563,34 @@ void MESH_OT_duplicate(wmOperatorType *ot) ot->name = "Duplicate"; ot->description = "Duplicate selected vertices, edges or faces"; ot->idname = "MESH_OT_duplicate"; - + /* api callbacks */ ot->invoke = edbm_duplicate_invoke; ot->exec = edbm_duplicate_exec; - + ot->poll = ED_operator_editmesh; - + /* to give to transform */ RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Flip Normals Operator + * \{ */ static int edbm_flip_normals_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); - + if (!EDBM_op_callf( em, op, "reverse_faces faces=%hf flip_multires=%b", BM_ELEM_SELECT, true)) { return OPERATOR_CANCELLED; } - + EDBM_update_generic(em, true, false); return OPERATOR_FINISHED; @@ -1522,15 +1602,21 @@ void MESH_OT_flip_normals(wmOperatorType *ot) ot->name = "Flip Normals"; ot->description = "Flip the direction of selected faces' normals (and of their vertices)"; ot->idname = "MESH_OT_flip_normals"; - + /* api callbacks */ ot->exec = edbm_flip_normals_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Rotate Edge Operator + * \{ */ + /** * Rotate the edges between selected faces, otherwise rotate the selected edges. */ @@ -1564,7 +1650,7 @@ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op) } } } - + /* ok, we don't have two adjacent faces, but we do have two selected ones. * that's an error condition.*/ if (tot == 0) { @@ -1623,12 +1709,17 @@ void MESH_OT_edge_rotate(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_ccw", false, "Counter Clockwise", ""); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Hide Operator + * \{ */ static int edbm_hide_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); - + EDBM_mesh_hide(em, RNA_boolean_get(op->ptr, "unselected")); EDBM_update_generic(em, true, false); @@ -1642,18 +1733,24 @@ void MESH_OT_hide(wmOperatorType *ot) ot->name = "Hide Selection"; ot->idname = "MESH_OT_hide"; ot->description = "Hide (un)selected vertices, edges or faces"; - + /* api callbacks */ ot->exec = edbm_hide_exec; ot->poll = ED_operator_editmesh; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_boolean(ot->srna, "unselected", false, "Unselected", "Hide unselected rather than selected"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Reveal Operator + * \{ */ + static int edbm_reveal_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -1673,22 +1770,28 @@ void MESH_OT_reveal(wmOperatorType *ot) ot->name = "Reveal Hidden"; ot->idname = "MESH_OT_reveal"; ot->description = "Reveal all hidden vertices, edges and faces"; - + /* api callbacks */ ot->exec = edbm_reveal_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "select", true, "Select", ""); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Recalculate Normals Operator + * \{ */ + static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); - + /* doflip has to do with bmesh_rationalize_normals, it's an internal * thing */ if (!EDBM_op_callf(em, op, "recalc_face_normals faces=%hf", BM_ELEM_SELECT)) @@ -1709,18 +1812,22 @@ void MESH_OT_normals_make_consistent(wmOperatorType *ot) ot->name = "Make Normals Consistent"; ot->description = "Make face and vertex normals point either outside or inside the mesh"; ot->idname = "MESH_OT_normals_make_consistent"; - + /* api callbacks */ ot->exec = edbm_normals_make_consistent_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "inside", false, "Inside", ""); } +/** \} */ +/* -------------------------------------------------------------------- */ +/** \name Smooth Vertex Operator + * \{ */ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) { @@ -1744,12 +1851,12 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) } /* if there is a mirror modifier with clipping, flag the verts that - * are within tolerance of the plane(s) of reflection + * are within tolerance of the plane(s) of reflection */ for (md = obedit->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Mirror && (md->mode & eModifierMode_Realtime)) { MirrorModifierData *mmd = (MirrorModifierData *)md; - + if (mmd->flag & MOD_MIR_CLIPPING) { if (mmd->flag & MOD_MIR_AXIS_X) mirrx = true; @@ -1768,10 +1875,11 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) repeat = 1; for (i = 0; i < repeat; i++) { - if (!EDBM_op_callf(em, op, - "smooth_vert verts=%hv factor=%f mirror_clip_x=%b mirror_clip_y=%b mirror_clip_z=%b " - "clip_dist=%f use_axis_x=%b use_axis_y=%b use_axis_z=%b", - BM_ELEM_SELECT, fac, mirrx, mirry, mirrz, clip_dist, xaxis, yaxis, zaxis)) + if (!EDBM_op_callf( + em, op, + "smooth_vert verts=%hv factor=%f mirror_clip_x=%b mirror_clip_y=%b mirror_clip_z=%b " + "clip_dist=%f use_axis_x=%b use_axis_y=%b use_axis_z=%b", + BM_ELEM_SELECT, fac, mirrx, mirry, mirrz, clip_dist, xaxis, yaxis, zaxis)) { return OPERATOR_CANCELLED; } @@ -1786,19 +1894,20 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) EDBM_update_generic(em, true, false); return OPERATOR_FINISHED; -} - +} + + void MESH_OT_vertices_smooth(wmOperatorType *ot) { /* identifiers */ ot->name = "Smooth Vertex"; ot->description = "Flatten angles of selected vertices"; ot->idname = "MESH_OT_vertices_smooth"; - + /* api callbacks */ ot->exec = edbm_do_smooth_vertex_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1809,6 +1918,12 @@ void MESH_OT_vertices_smooth(wmOperatorType *ot) RNA_def_boolean(ot->srna, "zaxis", true, "Z-Axis", "Smooth along the Z axis"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Laplacian Vertex Smooth Operator + * \{ */ + static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -1828,7 +1943,7 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op) if (f->len > 4) { BKE_report(op->reports, RPT_WARNING, "Selected faces must be triangles or quads"); return OPERATOR_CANCELLED; - } + } } } @@ -1846,11 +1961,12 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op) preserve_volume = RNA_boolean_get(op->ptr, "preserve_volume"); if (!repeat) repeat = 1; - + for (i = 0; i < repeat; i++) { - if (!EDBM_op_callf(em, op, - "smooth_laplacian_vert verts=%hv lambda_factor=%f lambda_border=%f use_x=%b use_y=%b use_z=%b preserve_volume=%b", - BM_ELEM_SELECT, lambda_factor, lambda_border, usex, usey, usez, preserve_volume)) + if (!EDBM_op_callf( + em, op, + "smooth_laplacian_vert verts=%hv lambda_factor=%f lambda_border=%f use_x=%b use_y=%b use_z=%b preserve_volume=%b", + BM_ELEM_SELECT, lambda_factor, lambda_border, usex, usey, usez, preserve_volume)) { return OPERATOR_CANCELLED; } @@ -1873,11 +1989,11 @@ void MESH_OT_vertices_smooth_laplacian(wmOperatorType *ot) ot->name = "Laplacian Smooth Vertex"; ot->description = "Laplacian smooth of selected vertices"; ot->idname = "MESH_OT_vertices_smooth_laplacian"; - + /* api callbacks */ ot->exec = edbm_do_smooth_laplacian_vertex_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1893,7 +2009,11 @@ void MESH_OT_vertices_smooth_laplacian(wmOperatorType *ot) RNA_def_boolean(ot->srna, "preserve_volume", true, "Preserve Volume", "Apply volume preservation after smooth"); } -/********************** Smooth/Solid Operators *************************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Set Faces Smooth Shading Operator + * \{ */ static void mesh_set_smooth_faces(BMEditMesh *em, short smooth) { @@ -1901,7 +2021,7 @@ static void mesh_set_smooth_faces(BMEditMesh *em, short smooth) BMFace *efa; if (em == NULL) return; - + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_elem_flag_set(efa, BM_ELEM_SMOOTH, smooth); @@ -1936,6 +2056,12 @@ void MESH_OT_faces_shade_smooth(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Set Faces Flat Shading Operator + * \{ */ + static int edbm_faces_shade_flat_exec(bContext *C, wmOperator *UNUSED(op)) { Object *obedit = CTX_data_edit_object(C); @@ -1963,8 +2089,11 @@ void MESH_OT_faces_shade_flat(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ -/********************** UV/Color Operators *************************/ +/* -------------------------------------------------------------------- */ +/** \name UV/Color Rotate/Reverse Operator + * \{ */ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op) { @@ -2134,6 +2263,11 @@ void MESH_OT_colors_reverse(wmOperatorType *ot) //RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror colors around"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Merge Vertices Operator + * \{ */ enum { MESH_MERGE_LAST = 1, @@ -2170,7 +2304,7 @@ static bool merge_firstlast(BMEditMesh *em, const bool use_first, const bool use if (!BM_elem_flag_test(mergevert, BM_ELEM_SELECT)) return false; - + if (use_uvmerge) { if (!EDBM_op_callf(em, wmop, "pointmerge_facedata verts=%hv vert_snap=%e", BM_ELEM_SELECT, mergevert)) return false; @@ -2182,8 +2316,9 @@ static bool merge_firstlast(BMEditMesh *em, const bool use_first, const bool use return true; } -static bool merge_target(BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob, - const bool use_cursor, const bool use_uvmerge, wmOperator *wmop) +static bool merge_target( + BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob, + const bool use_cursor, const bool use_uvmerge, wmOperator *wmop) { BMIter iter; BMVert *v; @@ -2204,7 +2339,7 @@ static bool merge_target(BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob, add_v3_v3(cent, v->co); i++; } - + if (!i) return false; @@ -2216,7 +2351,7 @@ static bool merge_target(BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob, if (!vco) return false; - + if (use_uvmerge) { if (!EDBM_op_callf(em, wmop, "average_vert_facedata verts=%hv", BM_ELEM_SELECT)) return false; @@ -2283,14 +2418,14 @@ static const EnumPropertyItem merge_type_items[] = { }; static const EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) -{ +{ Object *obedit; EnumPropertyItem *item = NULL; int totitem = 0; - + if (!C) /* needed for docs */ return merge_type_items; - + obedit = CTX_data_edit_object(C); if (obedit && obedit->type == OB_MESH) { BMEditMesh *em = BKE_editmesh_from_object(obedit); @@ -2320,7 +2455,7 @@ static const EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *UNUSED( return item; } - + return NULL; } @@ -2345,6 +2480,11 @@ void MESH_OT_merge(wmOperatorType *ot) RNA_def_boolean(ot->srna, "uvs", false, "UVs", "Move UVs according to merge"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Remove Doubles Operator + * \{ */ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) { @@ -2367,9 +2507,10 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) if (use_unselected) { - EDBM_op_init(em, &bmop, op, - "automerge verts=%hv dist=%f", - BM_ELEM_SELECT, threshold); + EDBM_op_init( + em, &bmop, op, + "automerge verts=%hv dist=%f", + BM_ELEM_SELECT, threshold); BMO_op_exec(em->bm, &bmop); if (!EDBM_op_finish(em, &bmop, op, true)) { @@ -2377,9 +2518,10 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) } } else { - EDBM_op_init(em, &bmop, op, - "find_doubles verts=%hv dist=%f", - BM_ELEM_SELECT, threshold); + EDBM_op_init( + em, &bmop, op, + "find_doubles verts=%hv dist=%f", + BM_ELEM_SELECT, threshold); BMO_op_exec(em->bm, &bmop); if (!EDBM_op_callf(em, op, "weld_verts targetmap=%S", &bmop, "targetmap.out")) { @@ -2391,7 +2533,7 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } } - + count = totvert_orig - em->bm->totvert; BKE_reportf(op->reports, RPT_INFO, "Removed %d vertices", count); @@ -2423,8 +2565,11 @@ void MESH_OT_remove_doubles(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_unselected", false, "Unselected", "Merge selected to other unselected vertices"); } +/** \} */ -/************************ Shape Operators *************************/ +/* -------------------------------------------------------------------- */ +/** \name Shape Key Propagate Operator + * \{ */ /* BMESH_TODO this should be properly encapsulated in a bmop. but later.*/ static void shape_propagate(BMEditMesh *em, wmOperator *op) @@ -2438,7 +2583,7 @@ static void shape_propagate(BMEditMesh *em, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Mesh does not have shape keys"); return; } - + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) continue; @@ -2489,6 +2634,12 @@ void MESH_OT_shape_propagate_to_all(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Blend from Shape Operator + * \{ */ + /* BMESH_TODO this should be properly encapsulated in a bmop. but later.*/ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op) { @@ -2515,23 +2666,23 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op) if (key) { kb = BLI_findlink(&key->block, shape); } - + /* perform blending on selected vertices*/ BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) continue; - + /* get coordinates of shapekey we're blending from */ sco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, shape); copy_v3_v3(co, sco); - + if (use_add) { /* in add mode, we add relative shape key offset */ if (kb) { const float *rco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, kb->relative); sub_v3_v3v3(co, co, rco); } - + madd_v3_v3fl(eve->co, co, blend); } else { @@ -2546,7 +2697,7 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op) } static const EnumPropertyItem *shape_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) -{ +{ Object *obedit = CTX_data_edit_object(C); BMEditMesh *em; EnumPropertyItem *item = NULL; @@ -2619,6 +2770,12 @@ void MESH_OT_blend_from_shape(wmOperatorType *ot) RNA_def_boolean(ot->srna, "add", true, "Add", "Add rather than blend between shapes"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Solidify Mesh Operator + * \{ */ + static int edbm_solidify_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -2673,6 +2830,12 @@ void MESH_OT_solidify(wmOperatorType *ot) RNA_def_property_ui_range(prop, -10.0, 10.0, 0.1, 4); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Knife Subdivide Operator + * \{ */ + /* ******************************************************************** */ /* Knife Subdivide Tool. Subdivides edges intersected by a mouse trail * drawn by user. @@ -2706,8 +2869,9 @@ static const EnumPropertyItem knife_items[] = { /* bm_edge_seg_isect() Determines if and where a mouse trail intersects an BMEdge */ -static float bm_edge_seg_isect(const float sco_a[2], const float sco_b[2], - float (*mouse_path)[2], int len, char mode, int *isected) +static float bm_edge_seg_isect( + const float sco_a[2], const float sco_b[2], + float (*mouse_path)[2], int len, char mode, int *isected) { #define MAXSLOPE 100000 float x11, y11, x12 = 0, y12 = 0, x2max, x2min, y2max; @@ -2716,17 +2880,17 @@ static float bm_edge_seg_isect(const float sco_a[2], const float sco_b[2], float yi, x1min, x1max, y1max, y1min, perc = 0; float threshold = 0.0; int i; - + //threshold = 0.000001; /* tolerance for vertex intersection */ // XXX threshold = scene->toolsettings->select_thresh / 100; - + /* Get screen coords of verts */ x21 = sco_a[0]; y21 = sco_a[1]; - + x22 = sco_b[0]; y22 = sco_b[1]; - + xdiff2 = (x22 - x21); if (xdiff2) { m2 = (y22 - y21) / xdiff2; @@ -2752,7 +2916,7 @@ static float bm_edge_seg_isect(const float sco_a[2], const float sco_b[2], } x12 = mouse_path[i][0]; y12 = mouse_path[i][1]; - + /* test e->v1 */ if ((x11 == x21 && y11 == y21) || (x12 == x21 && y12 == y21)) { perc = 0; @@ -2767,7 +2931,7 @@ static float bm_edge_seg_isect(const float sco_a[2], const float sco_b[2], } } } - + /* now check for edge intersect (may produce vertex intersection as well) */ for (i = 0; i < len; i++) { if (i > 0) { @@ -2780,14 +2944,14 @@ static float bm_edge_seg_isect(const float sco_a[2], const float sco_b[2], } x12 = mouse_path[i][0]; y12 = mouse_path[i][1]; - + /* Perp. Distance from point to line */ if (m2 != MAXSLOPE) dist = (y12 - m2 * x12 - b2); /* /sqrt(m2 * m2 + 1); Only looking for */ /* change in sign. Skip extra math */ else dist = x22 - x12; - + if (i == 0) lastdist = dist; - + /* if dist changes sign, and intersect point in edge's Bound Box */ if ((lastdist * dist) <= 0) { xdiff1 = (x12 - x11); /* Equation of line between last 2 points */ @@ -2803,14 +2967,14 @@ static float bm_edge_seg_isect(const float sco_a[2], const float sco_b[2], x2min = min_ff(x21, x22) - 0.001f; /* due to round off error */ y2max = max_ff(y21, y22) + 0.001f; y2min = min_ff(y21, y22) - 0.001f; - + /* Found an intersect, calc intersect point */ if (m1 == m2) { /* co-incident lines */ /* cut at 50% of overlap area */ x1max = max_ff(x11, x12); x1min = min_ff(x11, x12); xi = (min_ff(x2max, x1max) + max_ff(x2min, x1min)) / 2.0f; - + y1max = max_ff(y11, y12); y1min = min_ff(y11, y12); yi = (min_ff(y2max, y1max) + max_ff(y2min, y1min)) / 2.0f; @@ -2827,7 +2991,7 @@ static float bm_edge_seg_isect(const float sco_a[2], const float sco_b[2], xi = (b1 - b2) / (m2 - m1); yi = (b1 * m2 - m1 * b2) / (m2 - m1); } - + /* Intersect inside bounding box of edge?*/ if ((xi >= x2min) && (xi <= x2max) && (yi <= y2max) && (yi >= y2min)) { /* test for vertex intersect that may be 'close enough'*/ @@ -2850,7 +3014,7 @@ static float bm_edge_seg_isect(const float sco_a[2], const float sco_b[2], if ((m2 <= 1.0f) && (m2 >= -1.0f)) perc = (xi - x21) / (x22 - x21); else perc = (yi - y21) / (y22 - y21); /* lower slope more accurate */ //isect = 32768.0 * (perc + 0.0000153); /* Percentage in 1 / 32768ths */ - + break; } } @@ -2879,11 +3043,11 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) /* allocd vars */ float (*screen_vert_coords)[2], (*sco)[2], (*mouse_path)[2]; - + /* edit-object needed for matrix, and ar->regiondata for projections to work */ if (ELEM(NULL, obedit, ar, ar->regiondata)) return OPERATOR_CANCELLED; - + if (bm->totvertsel < 2) { BKE_report(op->reports, RPT_ERROR, "No edges are selected to operate on"); return OPERATOR_CANCELLED; @@ -2968,7 +3132,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) BMO_slot_bool_set(bmop.slots_in, "use_grid_fill", false); BMO_slot_float_set(bmop.slots_in, "radius", 0); - + BMO_op_exec(bm, &bmop); if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; @@ -2986,13 +3150,13 @@ void MESH_OT_knife_cut(wmOperatorType *ot) ot->name = "Knife Cut"; ot->description = "Cut selected edges and faces into parts"; ot->idname = "MESH_OT_knife_cut"; - + ot->invoke = WM_gesture_lines_invoke; ot->modal = WM_gesture_lines_modal; ot->exec = edbm_knife_cut_exec; - + ot->poll = EDBM_view3d_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -3002,13 +3166,16 @@ void MESH_OT_knife_cut(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); RNA_def_enum(ot->srna, "type", knife_items, KNIFE_EXACT, "Type", ""); - + /* internal */ RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, BC_NUMCURSORS, "Cursor", "", 0, BC_NUMCURSORS); } +/** \} */ -/* *************** Operator: separate parts *************/ +/* -------------------------------------------------------------------- */ +/** \name Separate Parts Operator + * \{ */ enum { MESH_SEPARATE_SELECTED = 0, @@ -3059,7 +3226,7 @@ static Base *mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMe BM_mesh_free(bm_new); ((Mesh *)base_new->object->data)->edit_btmesh = NULL; - + return base_new; } @@ -3287,7 +3454,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); const int type = RNA_enum_get(op->ptr, "type"); int retval = 0; - + if (ED_operator_editmesh(C)) { Base *base = CTX_data_active_base(C); BMEditMesh *em = BKE_editmesh_from_object(base->object); @@ -3400,18 +3567,23 @@ void MESH_OT_separate(wmOperatorType *ot) ot->name = "Separate"; ot->description = "Separate selected geometry into a new mesh"; ot->idname = "MESH_OT_separate"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = edbm_separate_exec; ot->poll = ED_operator_scene_editable; /* object and editmode */ - + /* flags */ ot->flag = OPTYPE_UNDO; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_separate_types, MESH_SEPARATE_SELECTED, "Type", ""); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Triangle Fill Operator + * \{ */ static int edbm_fill_exec(bContext *C, wmOperator *op) { @@ -3433,9 +3605,9 @@ static int edbm_fill_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + BMO_op_exec(em->bm, &bmop); - + if (totface_orig != em->bm->totface) { /* select new geometry */ BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_FACE | BM_EDGE, BM_ELEM_SELECT, true); @@ -3473,9 +3645,11 @@ void MESH_OT_fill(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_beauty", true, "Beauty", "Use best triangulation division"); } +/** \} */ /* -------------------------------------------------------------------- */ -/* Grid Fill (and helper functions) */ +/** \name Grid Fill Operator + * \{ */ static bool bm_edge_test_fill_grid_cb(BMEdge *e, void *UNUSED(bm_v)) { @@ -3666,10 +3840,11 @@ static int edbm_fill_grid_exec(bContext *C, wmOperator *op) /* end tricky prepare code */ - if (!EDBM_op_init(em, &bmop, op, - "grid_fill edges=%he mat_nr=%i use_smooth=%b use_interp_simple=%b", - use_prepare ? BM_ELEM_TAG : BM_ELEM_SELECT, - em->mat_nr, use_smooth, use_interp_simple)) + if (!EDBM_op_init( + em, &bmop, op, + "grid_fill edges=%he mat_nr=%i use_smooth=%b use_interp_simple=%b", + use_prepare ? BM_ELEM_TAG : BM_ELEM_SELECT, + em->mat_nr, use_smooth, use_interp_simple)) { return OPERATOR_CANCELLED; } @@ -3719,6 +3894,12 @@ void MESH_OT_fill_grid(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_interp_simple", false, "Simple Blending", ""); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Hole Fill Operator + * \{ */ + static int edbm_fill_holes_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -3758,6 +3939,12 @@ void MESH_OT_fill_holes(wmOperatorType *ot) "Sides", "Number of sides in hole required to fill (zero fills all holes)", 0, 100); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Beauty Fill Operator + * \{ */ + static int edbm_beautify_fill_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -3775,9 +3962,10 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op) BMEdge *e; BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { - BM_elem_flag_set(e, BM_ELEM_TAG, - (BM_elem_flag_test(e, BM_ELEM_SELECT) && - BM_edge_calc_face_angle_ex(e, angle_max) < angle_limit)); + BM_elem_flag_set( + e, BM_ELEM_TAG, + (BM_elem_flag_test(e, BM_ELEM_SELECT) && + BM_edge_calc_face_angle_ex(e, angle_max) < angle_limit)); } @@ -3793,7 +3981,7 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op) } EDBM_update_generic(em, true, true); - + return OPERATOR_FINISHED; } @@ -3819,8 +4007,11 @@ void MESH_OT_beautify_fill(wmOperatorType *ot) RNA_def_property_float_default(prop, DEG2RADF(180.0f)); } +/** \} */ -/********************** Poke Face **********************/ +/* -------------------------------------------------------------------- */ +/** \name Poke Face Operator + * \{ */ static int edbm_poke_face_exec(bContext *C, wmOperator *op) { @@ -3880,7 +4071,11 @@ void MESH_OT_poke(wmOperatorType *ot) "Poke Center", "Poke Face Center Calculation"); } -/********************** Quad/Tri Operators *************************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Triangulate Face Operator + * \{ */ static int edbm_quads_convert_to_tris_exec(bContext *C, wmOperator *op) { @@ -3935,6 +4130,12 @@ void MESH_OT_quads_convert_to_tris(wmOperatorType *ot) "Polygon Method", "Method for splitting the polygons into triangles"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Convert to Quads Operator + * \{ */ + static int edbm_tris_convert_to_quads_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -4025,10 +4226,10 @@ void MESH_OT_tris_convert_to_quads(wmOperatorType *ot) join_triangle_props(ot); } +/** \} */ /* -------------------------------------------------------------------- */ - -/** \name Decimate +/** \name Decimate Operator * * \note The function to decimate is intended for use as a modifier, * while its handy allow access as a tool - this does cause access to be a little awkward @@ -4214,9 +4415,9 @@ void MESH_OT_decimate(wmOperatorType *ot) /** \} */ - /* -------------------------------------------------------------------- */ -/* Dissolve */ +/** \name Dissolve Vertices Operator + * \{ */ static void edbm_dissolve_prop__use_verts(wmOperatorType *ot, bool value, int flag) { @@ -4248,9 +4449,10 @@ static int edbm_dissolve_verts_exec(bContext *C, wmOperator *op) const bool use_face_split = RNA_boolean_get(op->ptr, "use_face_split"); const bool use_boundary_tear = RNA_boolean_get(op->ptr, "use_boundary_tear"); - if (!EDBM_op_callf(em, op, - "dissolve_verts verts=%hv use_face_split=%b use_boundary_tear=%b", - BM_ELEM_SELECT, use_face_split, use_boundary_tear)) + if (!EDBM_op_callf( + em, op, + "dissolve_verts verts=%hv use_face_split=%b use_boundary_tear=%b", + BM_ELEM_SELECT, use_face_split, use_boundary_tear)) { return OPERATOR_CANCELLED; } @@ -4278,6 +4480,12 @@ void MESH_OT_dissolve_verts(wmOperatorType *ot) edbm_dissolve_prop__use_boundary_tear(ot); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Dissolve Edges Operator + * \{ */ + static int edbm_dissolve_edges_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -4286,9 +4494,10 @@ static int edbm_dissolve_edges_exec(bContext *C, wmOperator *op) const bool use_verts = RNA_boolean_get(op->ptr, "use_verts"); const bool use_face_split = RNA_boolean_get(op->ptr, "use_face_split"); - if (!EDBM_op_callf(em, op, - "dissolve_edges edges=%he use_verts=%b use_face_split=%b", - BM_ELEM_SELECT, use_verts, use_face_split)) + if (!EDBM_op_callf( + em, op, + "dissolve_edges edges=%he use_verts=%b use_face_split=%b", + BM_ELEM_SELECT, use_verts, use_face_split)) { return OPERATOR_CANCELLED; } @@ -4316,6 +4525,12 @@ void MESH_OT_dissolve_edges(wmOperatorType *ot) edbm_dissolve_prop__use_face_split(ot); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Dissolve Faces Operator + * \{ */ + static int edbm_dissolve_faces_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -4354,6 +4569,11 @@ void MESH_OT_dissolve_faces(wmOperatorType *ot) edbm_dissolve_prop__use_verts(ot, false, 0); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Dissolve (Context Sensitive) Operator + * \{ */ static int edbm_dissolve_mode_exec(bContext *C, wmOperator *op) { @@ -4399,6 +4619,12 @@ void MESH_OT_dissolve_mode(wmOperatorType *ot) edbm_dissolve_prop__use_boundary_tear(ot); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Limited Dissolve Operator + * \{ */ + static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -4476,6 +4702,12 @@ void MESH_OT_dissolve_limited(wmOperatorType *ot) "Delimit dissolve operation"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Degenerate Dissolve Operator + * \{ */ + static int edbm_dissolve_degenerate_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -4520,6 +4752,11 @@ void MESH_OT_dissolve_degenerate(wmOperatorType *ot) "Minimum distance between elements to merge", 1e-5f, 10.0f); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Delete Edge-Loop Operator + * \{ */ /* internally uses dissolve */ static int edbm_delete_edgeloop_exec(bContext *C, wmOperator *op) @@ -4546,9 +4783,10 @@ static int edbm_delete_edgeloop_exec(bContext *C, wmOperator *op) } } - if (!EDBM_op_callf(em, op, - "dissolve_edges edges=%he use_verts=%b use_face_split=%b", - BM_ELEM_SELECT, true, use_face_split)) + if (!EDBM_op_callf( + em, op, + "dissolve_edges edges=%he use_verts=%b use_face_split=%b", + BM_ELEM_SELECT, true, use_face_split)) { return OPERATOR_CANCELLED; } @@ -4580,6 +4818,12 @@ void MESH_OT_delete_edgeloop(wmOperatorType *ot) "Split off face corners to maintain surrounding geometry"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Split Geometry Operator + * \{ */ + static int edbm_split_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_edit_object(C); @@ -4617,16 +4861,21 @@ void MESH_OT_split(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/****************************************************************************** - * qsort routines. - * Now unified, for vertices/edges/faces. */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Sort Geometry Elements Operator + * + * Unified for vertices/edges/faces. + * + * \{ */ enum { SRT_VIEW_ZAXIS = 1, /* Use view Z (deep) axis. */ SRT_VIEW_XAXIS, /* Use view X (left to right) axis. */ SRT_CURSOR_DISTANCE, /* Use distance from element to 3D cursor. */ SRT_MATERIAL, /* Face only: use mat number. */ - SRT_SELECTED, /* Move selected elements in first, without modifying + SRT_SELECTED, /* Move selected elements in first, without modifying * relative order of selected and unselected elements. */ SRT_RANDOMIZE, /* Randomize selected elements. */ SRT_REVERSE, /* Reverse current order of selected elements. */ @@ -4645,10 +4894,11 @@ static int bmelemsort_comp(const void *v1, const void *v2) } /* Reorders vertices/edges/faces using a given methods. Loops are not supported. */ -static void sort_bmelem_flag(Scene *scene, Object *ob, - View3D *v3d, RegionView3D *rv3d, - const int types, const int flag, const int action, - const int reverse, const unsigned int seed) +static void sort_bmelem_flag( + Scene *scene, Object *ob, + View3D *v3d, RegionView3D *rv3d, + const int types, const int flag, const int action, + const int reverse, const unsigned int seed) { BMEditMesh *em = BKE_editmesh_from_object(ob); @@ -5114,8 +5364,9 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op) RNA_enum_set(op->ptr, "elements", elem_types); } - sort_bmelem_flag(scene, ob, v3d, rv3d, - elem_types, BM_ELEM_SELECT, action, use_reverse, seed); + sort_bmelem_flag( + scene, ob, v3d, rv3d, + elem_types, BM_ELEM_SELECT, action, use_reverse, seed); return OPERATOR_FINISHED; } @@ -5204,7 +5455,11 @@ void MESH_OT_sort_elements(wmOperatorType *ot) RNA_def_int(ot->srna, "seed", 0, 0, INT_MAX, "Seed", "Seed for random-based operations", 0, 255); } -/****** end of qsort stuff ****/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Noise (Deform Vertices) Operator + * \{ */ static int edbm_noise_exec(bContext *C, wmOperator *op) { @@ -5237,7 +5492,7 @@ static int edbm_noise_exec(bContext *C, wmOperator *op) vec[0] = fac * (b2 - BLI_hnoise(tex->noisesize, eve->co[0] + ofs, eve->co[1], eve->co[2])); vec[1] = fac * (b2 - BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1] + ofs, eve->co[2])); vec[2] = fac * (b2 - BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1], eve->co[2] + ofs)); - + add_v3_v3(eve->co, vec); } } @@ -5278,6 +5533,11 @@ void MESH_OT_noise(wmOperatorType *ot) RNA_def_float(ot->srna, "factor", 0.1f, -1e4f, 1e4f, "Factor", "", 0.0f, 1.0f); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Bridge Operator + * \{ */ enum { MESH_BRIDGELOOP_SINGLE = 0, @@ -5364,9 +5624,10 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op) edge_hflag = BM_ELEM_SELECT; } - EDBM_op_init(em, &bmop, op, - "bridge_loops edges=%he use_pairs=%b use_cyclic=%b use_merge=%b merge_factor=%f twist_offset=%i", - edge_hflag, use_pairs, use_cyclic, use_merge, merge_factor, twist_offset); + EDBM_op_init( + em, &bmop, op, + "bridge_loops edges=%he use_pairs=%b use_cyclic=%b use_merge=%b merge_factor=%f twist_offset=%i", + edge_hflag, use_pairs, use_cyclic, use_merge, merge_factor, twist_offset); if (use_faces && totface_del) { int i; @@ -5374,9 +5635,10 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op) for (i = 0; i < totface_del; i++) { BM_elem_flag_enable(totface_del_arr[i], BM_ELEM_TAG); } - BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS, - "delete geom=%hf context=%i", - BM_ELEM_TAG, DEL_FACES_KEEP_BOUNDARY); + BMO_op_callf( + em->bm, BMO_FLAG_DEFAULTS, + "delete geom=%hf context=%i", + BM_ELEM_TAG, DEL_FACES_KEEP_BOUNDARY); } BMO_op_exec(em->bm, &bmop); @@ -5442,11 +5704,11 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot) ot->name = "Bridge Edge Loops"; ot->description = "Make faces between two or more edge loops"; ot->idname = "MESH_OT_bridge_edge_loops"; - + /* api callbacks */ ot->exec = edbm_bridge_edge_loops_exec; ot->poll = ED_operator_editmesh; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -5460,6 +5722,12 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot) mesh_operator_edgering_props(ot, 0, 0); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Wire-Frame Operator + * \{ */ + static int edbm_wireframe_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -5474,11 +5742,12 @@ static int edbm_wireframe_exec(bContext *C, wmOperator *op) const float thickness = RNA_float_get(op->ptr, "thickness"); const float offset = RNA_float_get(op->ptr, "offset"); - EDBM_op_init(em, &bmop, op, - "wireframe faces=%hf use_replace=%b use_boundary=%b use_even_offset=%b use_relative_offset=%b " - "use_crease=%b crease_weight=%f thickness=%f offset=%f", - BM_ELEM_SELECT, use_replace, use_boundary, use_even_offset, use_relative_offset, - use_crease, crease_weight, thickness, offset); + EDBM_op_init( + em, &bmop, op, + "wireframe faces=%hf use_replace=%b use_boundary=%b use_even_offset=%b use_relative_offset=%b " + "use_crease=%b crease_weight=%f thickness=%f offset=%f", + BM_ELEM_SELECT, use_replace, use_boundary, use_even_offset, use_relative_offset, + use_crease, crease_weight, thickness, offset); BMO_op_exec(em->bm, &bmop); @@ -5524,6 +5793,12 @@ void MESH_OT_wireframe(wmOperatorType *ot) RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 2); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Offset Edge-Loop Operator + * \{ */ + static int edbm_offset_edgeloop_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -5578,6 +5853,12 @@ void MESH_OT_offset_edge_loops(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_cap_endpoint", false, "Cap Endpoint", "Extend loop around end-points"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Convex Hull Operator + * \{ */ + #ifdef WITH_BULLET static int edbm_convex_hull_exec(bContext *C, wmOperator *op) { @@ -5585,10 +5866,11 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(obedit); BMOperator bmop; - EDBM_op_init(em, &bmop, op, "convex_hull input=%hvef " - "use_existing_faces=%b", - BM_ELEM_SELECT, - RNA_boolean_get(op->ptr, "use_existing_faces")); + EDBM_op_init( + em, &bmop, op, "convex_hull input=%hvef " + "use_existing_faces=%b", + BM_ELEM_SELECT, + RNA_boolean_get(op->ptr, "use_existing_faces")); BMO_op_exec(em->bm, &bmop); /* Hull fails if input is coplanar */ @@ -5601,8 +5883,9 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) /* Delete unused vertices, edges, and faces */ if (RNA_boolean_get(op->ptr, "delete_unused")) { - if (!EDBM_op_callf(em, op, "delete geom=%S context=%i", - &bmop, "geom_unused.out", DEL_ONLYTAGGED)) + if (!EDBM_op_callf( + em, op, "delete geom=%S context=%i", + &bmop, "geom_unused.out", DEL_ONLYTAGGED)) { EDBM_op_finish(em, &bmop, op, true); return OPERATOR_CANCELLED; @@ -5611,8 +5894,9 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) /* Delete hole edges/faces */ if (RNA_boolean_get(op->ptr, "make_holes")) { - if (!EDBM_op_callf(em, op, "delete geom=%S context=%i", - &bmop, "geom_holes.out", DEL_ONLYTAGGED)) + if (!EDBM_op_callf( + em, op, "delete geom=%S context=%i", + &bmop, "geom_holes.out", DEL_ONLYTAGGED)) { EDBM_op_finish(em, &bmop, op, true); return OPERATOR_CANCELLED; @@ -5680,7 +5964,13 @@ void MESH_OT_convex_hull(wmOperatorType *ot) join_triangle_props(ot); } -#endif +#endif /* WITH_BULLET */ + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Symmetrize Operator + * \{ */ static int mesh_symmetrize_exec(bContext *C, wmOperator *op) { @@ -5690,9 +5980,10 @@ static int mesh_symmetrize_exec(bContext *C, wmOperator *op) const float thresh = RNA_float_get(op->ptr, "threshold"); - EDBM_op_init(em, &bmop, op, - "symmetrize input=%hvef direction=%i dist=%f", - BM_ELEM_SELECT, RNA_enum_get(op->ptr, "direction"), thresh); + EDBM_op_init( + em, &bmop, op, + "symmetrize input=%hvef direction=%i dist=%f", + BM_ELEM_SELECT, RNA_enum_get(op->ptr, "direction"), thresh); BMO_op_exec(em->bm, &bmop); EDBM_flag_disable_all(em, BM_ELEM_SELECT); @@ -5723,12 +6014,19 @@ void MESH_OT_symmetrize(struct wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ot->prop = RNA_def_enum(ot->srna, "direction", rna_enum_symmetrize_direction_items, - BMO_SYMMETRIZE_NEGATIVE_X, - "Direction", "Which sides to copy from and to"); + ot->prop = RNA_def_enum( + ot->srna, "direction", rna_enum_symmetrize_direction_items, + BMO_SYMMETRIZE_NEGATIVE_X, + "Direction", "Which sides to copy from and to"); RNA_def_float(ot->srna, "threshold", 1e-4f, 0.0f, 10.0f, "Threshold", "", 1e-5f, 0.1f); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Snap to Symmetry Operator + * \{ */ + static int mesh_symmetry_snap_exec(bContext *C, wmOperator *op) { const float eps = 0.00001f; @@ -5847,16 +6145,23 @@ void MESH_OT_symmetry_snap(struct wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ot->prop = RNA_def_enum(ot->srna, "direction", rna_enum_symmetrize_direction_items, - BMO_SYMMETRIZE_NEGATIVE_X, - "Direction", "Which sides to copy from and to"); + ot->prop = RNA_def_enum( + ot->srna, "direction", rna_enum_symmetrize_direction_items, + BMO_SYMMETRIZE_NEGATIVE_X, + "Direction", "Which sides to copy from and to"); RNA_def_float_distance(ot->srna, "threshold", 0.05f, 0.0f, 10.0f, "Threshold", "", 1e-4f, 1.0f); RNA_def_float(ot->srna, "factor", 0.5f, 0.0f, 1.0f, "Factor", "", 0.0f, 1.0f); RNA_def_boolean(ot->srna, "use_center", true, "Center", "Snap mid verts to the axis center"); } +/** \} */ + #ifdef WITH_FREESTYLE +/* -------------------------------------------------------------------- */ +/** \name Mark Edge (FreeStyle) Operator + * \{ */ + static int edbm_mark_freestyle_edge_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -5922,6 +6227,12 @@ void MESH_OT_mark_freestyle_edge(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Mark Face (FreeStyle) Operator + * \{ */ + static int edbm_mark_freestyle_face_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -5986,4 +6297,6 @@ void MESH_OT_mark_freestyle_face(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -#endif +/** \} */ + +#endif /* WITH_FREESTYLE */ |