From 19483125f8da79cb270cb8d6df76b2e67100c089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 3 Jul 2020 15:19:52 +0200 Subject: Cleanup: Editors/Mesh, Clang-Tidy else-after-return fixes This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/editors/mesh` module. No functional changes. --- source/blender/editors/mesh/editmesh_bevel.c | 4 +- source/blender/editors/mesh/editmesh_extrude.c | 7 +- source/blender/editors/mesh/editmesh_inset.c | 314 ++++++++++----------- source/blender/editors/mesh/editmesh_intersect.c | 22 +- source/blender/editors/mesh/editmesh_knife.c | 58 ++-- .../blender/editors/mesh/editmesh_knife_project.c | 11 +- source/blender/editors/mesh/editmesh_loopcut.c | 9 +- .../blender/editors/mesh/editmesh_mask_extract.c | 4 +- source/blender/editors/mesh/editmesh_path.c | 4 +- source/blender/editors/mesh/editmesh_polybuild.c | 18 +- source/blender/editors/mesh/editmesh_rip.c | 137 +++++---- source/blender/editors/mesh/editmesh_select.c | 314 ++++++++++----------- .../blender/editors/mesh/editmesh_select_similar.c | 10 +- source/blender/editors/mesh/editmesh_tools.c | 38 +-- source/blender/editors/mesh/editmesh_utils.c | 25 +- source/blender/editors/mesh/mesh_data.c | 40 +-- source/blender/editors/mesh/mesh_mirror.c | 14 +- source/blender/editors/mesh/meshtools.c | 30 +- 18 files changed, 478 insertions(+), 581 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index d18f5de357f..58f8c85d820 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -626,7 +626,7 @@ static bool edbm_bevel_poll_property(const bContext *UNUSED(C), if (STREQ(prop_id, "offset") && offset_type == BEVEL_AMT_PERCENT) { return false; } - else if (STREQ(prop_id, "offset_pct") && offset_type != BEVEL_AMT_PERCENT) { + if (STREQ(prop_id, "offset_pct") && offset_type != BEVEL_AMT_PERCENT) { return false; } } @@ -729,7 +729,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) edbm_bevel_update_status_text(C, op); return OPERATOR_RUNNING_MODAL; } - else if (etype == MOUSEMOVE) { + if (etype == MOUSEMOVE) { if (!has_numinput) { edbm_bevel_mouse_set_value(op, event); edbm_bevel_calc(op); diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index bf6c5a2f829..5ad1b5d67da 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -424,10 +424,9 @@ static bool edbm_extrude_mesh(Object *obedit, BMEditMesh *em, wmOperator *op) if (changed) { return true; } - else { - BKE_report(op->reports, RPT_ERROR, "Not a valid selection for extrude"); - return false; - } + + BKE_report(op->reports, RPT_ERROR, "Not a valid selection for extrude"); + return false; } /* extrude without transform */ diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index 2eeada95eda..8d9837f123a 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -313,10 +313,9 @@ static bool edbm_inset_calc(wmOperator *op) if (!EDBM_op_finish(em, &bmop, op, true)) { continue; } - else { - EDBM_update_generic(obedit->data, true, true); - changed = true; - } + + EDBM_update_generic(obedit->data, true, true); + changed = true; } return changed; } @@ -387,186 +386,181 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event) edbm_inset_update_header(op, C); return OPERATOR_RUNNING_MODAL; } - else { - edbm_inset_cancel(C, op); - return OPERATOR_CANCELLED; - } + edbm_inset_cancel(C, op); + return OPERATOR_CANCELLED; } - else if ((event->type == opdata->launch_event) && (event->val == KM_RELEASE) && - RNA_boolean_get(op->ptr, "release_confirm")) { + if ((event->type == opdata->launch_event) && (event->val == KM_RELEASE) && + RNA_boolean_get(op->ptr, "release_confirm")) { edbm_inset_calc(op); edbm_inset_exit(C, op); return OPERATOR_FINISHED; } - else { - bool handled = false; - switch (event->type) { - case EVT_ESCKEY: - case RIGHTMOUSE: - edbm_inset_cancel(C, op); - return OPERATOR_CANCELLED; - - case MOUSEMOVE: - if (!has_numinput) { - float mdiff[2]; - float amount; - - mdiff[0] = opdata->mcenter[0] - event->mval[0]; - mdiff[1] = opdata->mcenter[1] - event->mval[1]; - - if (opdata->modify_depth) { - amount = opdata->old_depth + - ((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size) / - opdata->max_obj_scale; - } - else { - amount = opdata->old_thickness - - ((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size) / - opdata->max_obj_scale; - } - - /* Fake shift-transform... */ - if (opdata->shift) { - amount = (amount - opdata->shift_amount) * 0.1f + opdata->shift_amount; - } - - if (opdata->modify_depth) { - RNA_float_set(op->ptr, "depth", amount); - } - else { - amount = max_ff(amount, 0.0f); - RNA_float_set(op->ptr, "thickness", amount); - } - - if (edbm_inset_calc(op)) { - edbm_inset_update_header(op, C); - } - else { - edbm_inset_cancel(C, op); - return OPERATOR_CANCELLED; - } - handled = true; - } - break; - - case LEFTMOUSE: - case EVT_PADENTER: - case EVT_RETKEY: - if ((event->val == KM_PRESS) || - ((event->val == KM_RELEASE) && RNA_boolean_get(op->ptr, "release_confirm"))) { - edbm_inset_calc(op); - edbm_inset_exit(C, op); - return OPERATOR_FINISHED; - } - break; - case EVT_LEFTSHIFTKEY: - case EVT_RIGHTSHIFTKEY: - if (event->val == KM_PRESS) { - if (opdata->modify_depth) { - opdata->shift_amount = RNA_float_get(op->ptr, "depth"); - } - else { - opdata->shift_amount = RNA_float_get(op->ptr, "thickness"); - } - opdata->shift = true; - handled = true; + + bool handled = false; + switch (event->type) { + case EVT_ESCKEY: + case RIGHTMOUSE: + edbm_inset_cancel(C, op); + return OPERATOR_CANCELLED; + + case MOUSEMOVE: + if (!has_numinput) { + float mdiff[2]; + float amount; + + mdiff[0] = opdata->mcenter[0] - event->mval[0]; + mdiff[1] = opdata->mcenter[1] - event->mval[1]; + + if (opdata->modify_depth) { + amount = opdata->old_depth + + ((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size) / + opdata->max_obj_scale; } else { - opdata->shift_amount = 0.0f; - opdata->shift = false; - handled = true; + amount = opdata->old_thickness - + ((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size) / + opdata->max_obj_scale; } - break; - case EVT_LEFTCTRLKEY: - case EVT_RIGHTCTRLKEY: { - float mlen[2]; - - mlen[0] = opdata->mcenter[0] - event->mval[0]; - mlen[1] = opdata->mcenter[1] - event->mval[1]; + /* Fake shift-transform... */ + if (opdata->shift) { + amount = (amount - opdata->shift_amount) * 0.1f + opdata->shift_amount; + } - if (event->val == KM_PRESS) { - opdata->old_thickness = RNA_float_get(op->ptr, "thickness"); - if (opdata->shift) { - opdata->shift_amount = opdata->old_thickness; - } - opdata->modify_depth = true; + if (opdata->modify_depth) { + RNA_float_set(op->ptr, "depth", amount); } else { - opdata->old_depth = RNA_float_get(op->ptr, "depth"); - if (opdata->shift) { - opdata->shift_amount = opdata->old_depth; - } - opdata->modify_depth = false; + amount = max_ff(amount, 0.0f); + RNA_float_set(op->ptr, "thickness", amount); } - opdata->initial_length = len_v2(mlen); - edbm_inset_update_header(op, C); + if (edbm_inset_calc(op)) { + edbm_inset_update_header(op, C); + } + else { + edbm_inset_cancel(C, op); + return OPERATOR_CANCELLED; + } handled = true; - break; } - - case EVT_OKEY: - if (event->val == KM_PRESS) { - const bool use_outset = RNA_boolean_get(op->ptr, "use_outset"); - RNA_boolean_set(op->ptr, "use_outset", !use_outset); - if (edbm_inset_calc(op)) { - edbm_inset_update_header(op, C); - } - else { - edbm_inset_cancel(C, op); - return OPERATOR_CANCELLED; - } - handled = true; + break; + + case LEFTMOUSE: + case EVT_PADENTER: + case EVT_RETKEY: + if ((event->val == KM_PRESS) || + ((event->val == KM_RELEASE) && RNA_boolean_get(op->ptr, "release_confirm"))) { + edbm_inset_calc(op); + edbm_inset_exit(C, op); + return OPERATOR_FINISHED; + } + break; + case EVT_LEFTSHIFTKEY: + case EVT_RIGHTSHIFTKEY: + if (event->val == KM_PRESS) { + if (opdata->modify_depth) { + opdata->shift_amount = RNA_float_get(op->ptr, "depth"); + } + else { + opdata->shift_amount = RNA_float_get(op->ptr, "thickness"); } - break; - case EVT_BKEY: - if (event->val == KM_PRESS) { - const bool use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); - RNA_boolean_set(op->ptr, "use_boundary", !use_boundary); - if (edbm_inset_calc(op)) { - edbm_inset_update_header(op, C); - } - else { - edbm_inset_cancel(C, op); - return OPERATOR_CANCELLED; - } - handled = true; + opdata->shift = true; + handled = true; + } + else { + opdata->shift_amount = 0.0f; + opdata->shift = false; + handled = true; + } + break; + + case EVT_LEFTCTRLKEY: + case EVT_RIGHTCTRLKEY: { + float mlen[2]; + + mlen[0] = opdata->mcenter[0] - event->mval[0]; + mlen[1] = opdata->mcenter[1] - event->mval[1]; + + if (event->val == KM_PRESS) { + opdata->old_thickness = RNA_float_get(op->ptr, "thickness"); + if (opdata->shift) { + opdata->shift_amount = opdata->old_thickness; } - break; - case EVT_IKEY: - if (event->val == KM_PRESS) { - const bool use_individual = RNA_boolean_get(op->ptr, "use_individual"); - RNA_boolean_set(op->ptr, "use_individual", !use_individual); - if (edbm_inset_calc(op)) { - edbm_inset_update_header(op, C); - } - else { - edbm_inset_cancel(C, op); - return OPERATOR_CANCELLED; - } - handled = true; + opdata->modify_depth = true; + } + else { + opdata->old_depth = RNA_float_get(op->ptr, "depth"); + if (opdata->shift) { + opdata->shift_amount = opdata->old_depth; } - break; + opdata->modify_depth = false; + } + opdata->initial_length = len_v2(mlen); + + edbm_inset_update_header(op, C); + handled = true; + break; } - /* Modal numinput inactive, try to handle numeric inputs last... */ - if (!handled && event->val == KM_PRESS && handleNumInput(C, &opdata->num_input, event)) { - float amounts[2] = {RNA_float_get(op->ptr, "thickness"), RNA_float_get(op->ptr, "depth")}; - applyNumInput(&opdata->num_input, amounts); - amounts[0] = max_ff(amounts[0], 0.0f); - RNA_float_set(op->ptr, "thickness", amounts[0]); - RNA_float_set(op->ptr, "depth", amounts[1]); - - if (edbm_inset_calc(op)) { - edbm_inset_update_header(op, C); - return OPERATOR_RUNNING_MODAL; + case EVT_OKEY: + if (event->val == KM_PRESS) { + const bool use_outset = RNA_boolean_get(op->ptr, "use_outset"); + RNA_boolean_set(op->ptr, "use_outset", !use_outset); + if (edbm_inset_calc(op)) { + edbm_inset_update_header(op, C); + } + else { + edbm_inset_cancel(C, op); + return OPERATOR_CANCELLED; + } + handled = true; } - else { - edbm_inset_cancel(C, op); - return OPERATOR_CANCELLED; + break; + case EVT_BKEY: + if (event->val == KM_PRESS) { + const bool use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); + RNA_boolean_set(op->ptr, "use_boundary", !use_boundary); + if (edbm_inset_calc(op)) { + edbm_inset_update_header(op, C); + } + else { + edbm_inset_cancel(C, op); + return OPERATOR_CANCELLED; + } + handled = true; + } + break; + case EVT_IKEY: + if (event->val == KM_PRESS) { + const bool use_individual = RNA_boolean_get(op->ptr, "use_individual"); + RNA_boolean_set(op->ptr, "use_individual", !use_individual); + if (edbm_inset_calc(op)) { + edbm_inset_update_header(op, C); + } + else { + edbm_inset_cancel(C, op); + return OPERATOR_CANCELLED; + } + handled = true; } + break; + } + + /* Modal numinput inactive, try to handle numeric inputs last... */ + if (!handled && event->val == KM_PRESS && handleNumInput(C, &opdata->num_input, event)) { + float amounts[2] = {RNA_float_get(op->ptr, "thickness"), RNA_float_get(op->ptr, "depth")}; + applyNumInput(&opdata->num_input, amounts); + amounts[0] = max_ff(amounts[0], 0.0f); + RNA_float_set(op->ptr, "thickness", amounts[0]); + RNA_float_set(op->ptr, "depth", amounts[1]); + + if (edbm_inset_calc(op)) { + edbm_inset_update_header(op, C); + return OPERATOR_RUNNING_MODAL; } + edbm_inset_cancel(C, op); + return OPERATOR_CANCELLED; } return OPERATOR_RUNNING_MODAL; diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c index fd7cc2733ec..97bd6ee0039 100644 --- a/source/blender/editors/mesh/editmesh_intersect.c +++ b/source/blender/editors/mesh/editmesh_intersect.c @@ -60,9 +60,7 @@ static int bm_face_isect_self(BMFace *f, void *UNUSED(user_data)) if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { return 0; } - else { - return -1; - } + return -1; } /** @@ -73,12 +71,10 @@ static int bm_face_isect_pair(BMFace *f, void *UNUSED(user_data)) if (BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { return -1; } - else if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { + if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { return 1; } - else { - return 0; - } + return 0; } /** @@ -90,12 +86,10 @@ static int bm_face_isect_pair_swap(BMFace *f, void *UNUSED(user_data)) if (BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { return -1; } - else if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { + if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { return 0; } - else { - return 1; - } + return 1; } /** @@ -515,12 +509,10 @@ static int bm_edge_sort_length_cb(const void *e_a_v, const void *e_b_v) if (val_a > val_b) { return 1; } - else if (val_a < val_b) { + if (val_a < val_b) { return -1; } - else { - return 0; - } + return 0; } static void bm_face_split_by_edges_island_connect( diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 369c7735d20..adc3be6b2ac 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -649,28 +649,22 @@ static int linehit_compare(const void *vlh1, const void *vlh2) if (lh1->l < lh2->l) { return -1; } - else if (lh1->l > lh2->l) { + if (lh1->l > lh2->l) { return 1; } - else { - if (lh1->m < lh2->m) { - return -1; - } - else if (lh1->m > lh2->m) { - return 1; - } - else { - if (lh1->v < lh2->v) { - return -1; - } - else if (lh1->v > lh2->v) { - return 1; - } - else { - return 0; - } - } + if (lh1->m < lh2->m) { + return -1; + } + if (lh1->m > lh2->m) { + return 1; + } + if (lh1->v < lh2->v) { + return -1; } + if (lh1->v > lh2->v) { + return 1; + } + return 0; } /* @@ -816,11 +810,9 @@ static void knife_add_single_cut(KnifeTool_OpData *kcd, kfe->e = e_base; return; } - else { - if (knife_add_single_cut__is_linehit_outside_face(f, lh1, lh2->hit) || - knife_add_single_cut__is_linehit_outside_face(f, lh2, lh1->hit)) { - return; - } + if (knife_add_single_cut__is_linehit_outside_face(f, lh1, lh2->hit) || + knife_add_single_cut__is_linehit_outside_face(f, lh2, lh1->hit)) { + return; } /* Check if edge actually lies within face (might not, if this face is concave) */ @@ -1405,9 +1397,7 @@ static bool coinciding_edges(BMEdge *e1, BMEdge *e2) (equals_v3v3(co11, co22) && equals_v3v3(co12, co21))) { return true; } - else { - return false; - } + return false; } /* Callback used in point_is_visible to exclude hits on the faces that are the same @@ -2191,13 +2181,11 @@ static KnifeVert *knife_find_closest_vert( return curv; } - else { - if (fptr) { - *fptr = f; - } - return NULL; + if (fptr) { + *fptr = f; } + return NULL; } if (fptr) { @@ -2310,12 +2298,10 @@ static int sort_verts_by_dist_cb(void *co_p, const void *cur_a_p, const void *cu if (a_sq < b_sq) { return -1; } - else if (a_sq > b_sq) { + if (a_sq > b_sq) { return 1; } - else { - return 0; - } + return 0; } static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f) diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c index 10e8bfa529f..ed22d381a02 100644 --- a/source/blender/editors/mesh/editmesh_knife_project.c +++ b/source/blender/editors/mesh/editmesh_knife_project.c @@ -152,12 +152,11 @@ static int knifeproject_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - else { - BKE_report(op->reports, - RPT_ERROR, - "No other selected objects have wire or boundary edges to use for projection"); - return OPERATOR_CANCELLED; - } + + BKE_report(op->reports, + RPT_ERROR, + "No other selected objects have wire or boundary edges to use for projection"); + return OPERATOR_CANCELLED; } void MESH_OT_knife_project(wmOperatorType *ot) diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 0f52911c603..2f453369d92 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -451,11 +451,10 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event) "hold Alt for smooth")); return OPERATOR_RUNNING_MODAL; } - else { - ringsel_finish(C, op); - ringsel_exit(C, op); - return OPERATOR_FINISHED; - } + + ringsel_finish(C, op); + ringsel_exit(C, op); + return OPERATOR_FINISHED; } static int ringcut_invoke(bContext *C, wmOperator *op, const wmEvent *event) diff --git a/source/blender/editors/mesh/editmesh_mask_extract.c b/source/blender/editors/mesh/editmesh_mask_extract.c index 739bc5bdf7c..8eeba5007e1 100644 --- a/source/blender/editors/mesh/editmesh_mask_extract.c +++ b/source/blender/editors/mesh/editmesh_mask_extract.c @@ -66,9 +66,7 @@ static bool paint_mask_extract_poll(bContext *C) CTX_wm_operator_poll_msg_set(C, "The mask can not be extracted with dyntopo activated"); return false; } - else { - return ED_operator_object_active_editable_mesh(C); - } + return ED_operator_object_active_editable_mesh(C); } return false; } diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c index 7cde233c6b6..e7e27c2189f 100644 --- a/source/blender/editors/mesh/editmesh_path.c +++ b/source/blender/editors/mesh/editmesh_path.c @@ -642,10 +642,10 @@ static BMElem *edbm_elem_find_nearest(ViewContext *vc, const char htype) if ((em->selectmode & SCE_SELECT_VERTEX) && (htype == BM_VERT)) { return (BMElem *)EDBM_vert_find_nearest(vc, &dist); } - else if ((em->selectmode & SCE_SELECT_EDGE) && (htype == BM_EDGE)) { + if ((em->selectmode & SCE_SELECT_EDGE) && (htype == BM_EDGE)) { return (BMElem *)EDBM_edge_find_nearest(vc, &dist); } - else if ((em->selectmode & SCE_SELECT_FACE) && (htype == BM_FACE)) { + if ((em->selectmode & SCE_SELECT_FACE) && (htype == BM_FACE)) { return (BMElem *)EDBM_face_find_nearest(vc, &dist); } diff --git a/source/blender/editors/mesh/editmesh_polybuild.c b/source/blender/editors/mesh/editmesh_polybuild.c index c7bb45ccfe3..da3d16ba04f 100644 --- a/source/blender/editors/mesh/editmesh_polybuild.c +++ b/source/blender/editors/mesh/editmesh_polybuild.c @@ -247,9 +247,7 @@ static int edbm_polybuild_delete_at_cursor_invoke(bContext *C, WM_event_add_mousemove(vc.win); return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } void MESH_OT_polybuild_delete_at_cursor(wmOperatorType *ot) @@ -415,9 +413,7 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } void MESH_OT_polybuild_face_at_cursor(wmOperatorType *ot) @@ -470,7 +466,7 @@ static int edbm_polybuild_split_at_cursor_invoke(bContext *C, if (ele_act == NULL || ele_act->head.hflag == BM_FACE) { return OPERATOR_PASS_THROUGH; } - else if (ele_act->head.htype == BM_EDGE) { + if (ele_act->head.htype == BM_EDGE) { BMEdge *e_act = (BMEdge *)ele_act; mid_v3_v3v3(center, e_act->v1->co, e_act->v2->co); mul_m4_v3(vc.obedit->obmat, center); @@ -503,9 +499,7 @@ static int edbm_polybuild_split_at_cursor_invoke(bContext *C, return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } void MESH_OT_polybuild_split_at_cursor(wmOperatorType *ot) @@ -596,9 +590,7 @@ static int edbm_polybuild_dissolve_at_cursor_invoke(bContext *C, return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } void MESH_OT_polybuild_dissolve_at_cursor(wmOperatorType *ot) diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index e805507351c..89a90dcf12d 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -155,9 +155,7 @@ static float edbm_rip_edge_side_measure( dist_squared_to_line_segment_v2(fmval, e_v1_co, e_v2_co)) { return score; } - else { - return -score; - } + return -score; } /* - Advanced selection handling 'ripsel' functions ----- */ @@ -433,9 +431,7 @@ static UnorderedLoopPair *edbm_tagged_loop_pairs_to_fill(BMesh *bm) return uloop_pairs; } - else { - return NULL; - } + return NULL; } static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *uloop_pairs) @@ -658,89 +654,88 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed /* should never happen */ return OPERATOR_CANCELLED; } - else { - int vi_best = 0; - if (ese.ele) { - BM_select_history_remove(bm, ese.ele); - } + int vi_best = 0; - dist_sq = FLT_MAX; + if (ese.ele) { + BM_select_history_remove(bm, ese.ele); + } + + dist_sq = FLT_MAX; - /* in the loop below we find the best vertex to drag based on its connected geometry, - * either by its face corner, or connected edge (when no faces are attached) */ - for (i = 0; i < vout_len; i++) { + /* in the loop below we find the best vertex to drag based on its connected geometry, + * either by its face corner, or connected edge (when no faces are attached) */ + for (i = 0; i < vout_len; i++) { - if (BM_vert_is_wire(vout[i]) == false) { - /* find the best face corner */ - BM_ITER_ELEM (l, &iter, vout[i], BM_LOOPS_OF_VERT) { - if (!BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) { - float l_mid_co[3]; + if (BM_vert_is_wire(vout[i]) == false) { + /* find the best face corner */ + BM_ITER_ELEM (l, &iter, vout[i], BM_LOOPS_OF_VERT) { + if (!BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) { + float l_mid_co[3]; - edbm_calc_loop_co(l, l_mid_co); - d = edbm_rip_edgedist_squared( - region, projectMat, v->co, l_mid_co, fmval, INSET_DEFAULT); + edbm_calc_loop_co(l, l_mid_co); + d = edbm_rip_edgedist_squared( + region, projectMat, v->co, l_mid_co, fmval, INSET_DEFAULT); - if (d < dist_sq) { - dist_sq = d; - vi_best = i; - } + if (d < dist_sq) { + dist_sq = d; + vi_best = i; } } } - else { - BMEdge *e; - /* a wire vert, find the best edge */ - BM_ITER_ELEM (e, &iter, vout[i], BM_EDGES_OF_VERT) { - if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { - float e_mid_co[3]; - - mid_v3_v3v3(e_mid_co, e->v1->co, e->v2->co); - d = edbm_rip_edgedist_squared( - region, projectMat, v->co, e_mid_co, fmval, INSET_DEFAULT); - - if (d < dist_sq) { - dist_sq = d; - vi_best = i; - } + } + else { + BMEdge *e; + /* a wire vert, find the best edge */ + BM_ITER_ELEM (e, &iter, vout[i], BM_EDGES_OF_VERT) { + if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { + float e_mid_co[3]; + + mid_v3_v3v3(e_mid_co, e->v1->co, e->v2->co); + d = edbm_rip_edgedist_squared( + region, projectMat, v->co, e_mid_co, fmval, INSET_DEFAULT); + + if (d < dist_sq) { + dist_sq = d; + vi_best = i; } } } } + } - /* vout[0] == best - * vout[1] == glue - * vout[2+] == splice with glue (when vout_len > 2) - */ - if (vi_best != 0) { - SWAP(BMVert *, vout[0], vout[vi_best]); - vi_best = 0; - } + /* vout[0] == best + * vout[1] == glue + * vout[2+] == splice with glue (when vout_len > 2) + */ + if (vi_best != 0) { + SWAP(BMVert *, vout[0], vout[vi_best]); + vi_best = 0; + } - /* select the vert from the best region */ - v = vout[vi_best]; - BM_vert_select_set(bm, v, true); + /* select the vert from the best region */ + v = vout[vi_best]; + BM_vert_select_set(bm, v, true); - if (ese.ele) { - BM_select_history_store(bm, v); - } + if (ese.ele) { + BM_select_history_store(bm, v); + } - /* splice all others back together */ - if (vout_len > 2) { - for (i = 2; i < vout_len; i++) { - BM_vert_splice(bm, vout[1], vout[i]); - } + /* splice all others back together */ + if (vout_len > 2) { + for (i = 2; i < vout_len; i++) { + BM_vert_splice(bm, vout[1], vout[i]); } + } - if (do_fill) { - /* match extrude vert-order */ - BM_edge_create(bm, vout[1], vout[0], NULL, BM_CREATE_NOP); - } + if (do_fill) { + /* match extrude vert-order */ + BM_edge_create(bm, vout[1], vout[0], NULL, BM_CREATE_NOP); + } - MEM_freeN(vout); + MEM_freeN(vout); - return OPERATOR_FINISHED; - } + return OPERATOR_FINISHED; } if (!e_best) { @@ -1090,15 +1085,15 @@ static int edbm_rip_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* Ignore it. */ return OPERATOR_CANCELLED; } - else if (error_face_selected) { + if (error_face_selected) { BKE_report(op->reports, RPT_ERROR, "Cannot rip selected faces"); return OPERATOR_CANCELLED; } - else if (error_disconnected_vertices) { + if (error_disconnected_vertices) { BKE_report(op->reports, RPT_ERROR, "Cannot rip multiple disconnected vertices"); return OPERATOR_CANCELLED; } - else if (error_rip_failed) { + if (error_rip_failed) { BKE_report(op->reports, RPT_ERROR, "Rip failed"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index fe83d9f00ea..1198796cee1 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -316,65 +316,63 @@ BMVert *EDBM_vert_find_nearest_ex(ViewContext *vc, } return NULL; } - else { - struct NearestVertUserData data = {{0}}; - const struct NearestVertUserData_Hit *hit = NULL; - const eV3DProjTest clip_flag = RV3D_CLIPPING_ENABLED(vc->v3d, vc->rv3d) ? - V3D_PROJ_TEST_CLIP_DEFAULT : - V3D_PROJ_TEST_CLIP_DEFAULT & ~V3D_PROJ_TEST_CLIP_BB; - BMesh *prev_select_bm = NULL; - - static struct { - int index; - const BMVert *elem; - const BMesh *bm; - } prev_select = {0}; - - data.mval_fl[0] = vc->mval[0]; - data.mval_fl[1] = vc->mval[1]; - data.use_select_bias = use_select_bias; - data.use_cycle = use_cycle; - - for (; base_index < bases_len; base_index++) { - Base *base_iter = bases[base_index]; - ED_view3d_viewcontext_init_object(vc, base_iter->object); - if (use_cycle && prev_select.bm == vc->em->bm && - prev_select.elem == BM_vert_at_index_find_or_table(vc->em->bm, prev_select.index)) { - data.cycle_index_prev = prev_select.index; - /* No need to compare in the rest of the loop. */ - use_cycle = false; - } - else { - data.cycle_index_prev = 0; - } - data.hit.dist = data.hit_cycle.dist = data.hit.dist_bias = data.hit_cycle.dist_bias = - *r_dist; + struct NearestVertUserData data = {{0}}; + const struct NearestVertUserData_Hit *hit = NULL; + const eV3DProjTest clip_flag = RV3D_CLIPPING_ENABLED(vc->v3d, vc->rv3d) ? + V3D_PROJ_TEST_CLIP_DEFAULT : + V3D_PROJ_TEST_CLIP_DEFAULT & ~V3D_PROJ_TEST_CLIP_BB; + BMesh *prev_select_bm = NULL; + + static struct { + int index; + const BMVert *elem; + const BMesh *bm; + } prev_select = {0}; + + data.mval_fl[0] = vc->mval[0]; + data.mval_fl[1] = vc->mval[1]; + data.use_select_bias = use_select_bias; + data.use_cycle = use_cycle; + + for (; base_index < bases_len; base_index++) { + Base *base_iter = bases[base_index]; + ED_view3d_viewcontext_init_object(vc, base_iter->object); + if (use_cycle && prev_select.bm == vc->em->bm && + prev_select.elem == BM_vert_at_index_find_or_table(vc->em->bm, prev_select.index)) { + data.cycle_index_prev = prev_select.index; + /* No need to compare in the rest of the loop. */ + use_cycle = false; + } + else { + data.cycle_index_prev = 0; + } - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - mesh_foreachScreenVert(vc, findnearestvert__doClosest, &data, clip_flag); + data.hit.dist = data.hit_cycle.dist = data.hit.dist_bias = data.hit_cycle.dist_bias = *r_dist; - hit = (data.use_cycle && data.hit_cycle.vert) ? &data.hit_cycle : &data.hit; + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); + mesh_foreachScreenVert(vc, findnearestvert__doClosest, &data, clip_flag); - if (hit->dist < *r_dist) { - if (r_base_index) { - *r_base_index = base_index; - } - *r_dist = hit->dist; - prev_select_bm = vc->em->bm; + hit = (data.use_cycle && data.hit_cycle.vert) ? &data.hit_cycle : &data.hit; + + if (hit->dist < *r_dist) { + if (r_base_index) { + *r_base_index = base_index; } + *r_dist = hit->dist; + prev_select_bm = vc->em->bm; } + } - if (hit == NULL) { - return NULL; - } + if (hit == NULL) { + return NULL; + } - prev_select.index = hit->index; - prev_select.elem = hit->vert; - prev_select.bm = prev_select_bm; + prev_select.index = hit->index; + prev_select.elem = hit->vert; + prev_select.bm = prev_select_bm; - return hit->vert; - } + return hit->vert; } BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist) @@ -563,69 +561,67 @@ BMEdge *EDBM_edge_find_nearest_ex(ViewContext *vc, } return NULL; } - else { - struct NearestEdgeUserData data = {{0}}; - const struct NearestEdgeUserData_Hit *hit = NULL; - /* interpolate along the edge before doing a clipping plane test */ - const eV3DProjTest clip_flag = V3D_PROJ_TEST_CLIP_DEFAULT & ~V3D_PROJ_TEST_CLIP_BB; - BMesh *prev_select_bm = NULL; - - static struct { - int index; - const BMEdge *elem; - const BMesh *bm; - } prev_select = {0}; - - data.vc = *vc; - data.mval_fl[0] = vc->mval[0]; - data.mval_fl[1] = vc->mval[1]; - data.use_select_bias = use_select_bias; - data.use_cycle = use_cycle; - - for (; base_index < bases_len; base_index++) { - Base *base_iter = bases[base_index]; - ED_view3d_viewcontext_init_object(vc, base_iter->object); - if (use_cycle && prev_select.bm == vc->em->bm && - prev_select.elem == BM_edge_at_index_find_or_table(vc->em->bm, prev_select.index)) { - data.cycle_index_prev = prev_select.index; - /* No need to compare in the rest of the loop. */ - use_cycle = false; - } - else { - data.cycle_index_prev = 0; - } - data.hit.dist = data.hit_cycle.dist = data.hit.dist_bias = data.hit_cycle.dist_bias = - *r_dist; + struct NearestEdgeUserData data = {{0}}; + const struct NearestEdgeUserData_Hit *hit = NULL; + /* interpolate along the edge before doing a clipping plane test */ + const eV3DProjTest clip_flag = V3D_PROJ_TEST_CLIP_DEFAULT & ~V3D_PROJ_TEST_CLIP_BB; + BMesh *prev_select_bm = NULL; - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - mesh_foreachScreenEdge(vc, find_nearest_edge__doClosest, &data, clip_flag); + static struct { + int index; + const BMEdge *elem; + const BMesh *bm; + } prev_select = {0}; - hit = (data.use_cycle && data.hit_cycle.edge) ? &data.hit_cycle : &data.hit; + data.vc = *vc; + data.mval_fl[0] = vc->mval[0]; + data.mval_fl[1] = vc->mval[1]; + data.use_select_bias = use_select_bias; + data.use_cycle = use_cycle; - if (hit->dist < *r_dist) { - if (r_base_index) { - *r_base_index = base_index; - } - *r_dist = hit->dist; - prev_select_bm = vc->em->bm; - } + for (; base_index < bases_len; base_index++) { + Base *base_iter = bases[base_index]; + ED_view3d_viewcontext_init_object(vc, base_iter->object); + if (use_cycle && prev_select.bm == vc->em->bm && + prev_select.elem == BM_edge_at_index_find_or_table(vc->em->bm, prev_select.index)) { + data.cycle_index_prev = prev_select.index; + /* No need to compare in the rest of the loop. */ + use_cycle = false; } - - if (hit == NULL) { - return NULL; + else { + data.cycle_index_prev = 0; } - if (r_dist_center) { - *r_dist_center = hit->dist_center; + data.hit.dist = data.hit_cycle.dist = data.hit.dist_bias = data.hit_cycle.dist_bias = *r_dist; + + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); + mesh_foreachScreenEdge(vc, find_nearest_edge__doClosest, &data, clip_flag); + + hit = (data.use_cycle && data.hit_cycle.edge) ? &data.hit_cycle : &data.hit; + + if (hit->dist < *r_dist) { + if (r_base_index) { + *r_base_index = base_index; + } + *r_dist = hit->dist; + prev_select_bm = vc->em->bm; } + } - prev_select.index = hit->index; - prev_select.elem = hit->edge; - prev_select.bm = prev_select_bm; + if (hit == NULL) { + return NULL; + } - return hit->edge; + if (r_dist_center) { + *r_dist_center = hit->dist_center; } + + prev_select.index = hit->index; + prev_select.elem = hit->edge; + prev_select.bm = prev_select_bm; + + return hit->edge; } BMEdge *EDBM_edge_find_nearest(ViewContext *vc, float *r_dist) @@ -769,67 +765,65 @@ BMFace *EDBM_face_find_nearest_ex(ViewContext *vc, } return NULL; } - else { - struct NearestFaceUserData data = {{0}}; - const struct NearestFaceUserData_Hit *hit = NULL; - const eV3DProjTest clip_flag = V3D_PROJ_TEST_CLIP_DEFAULT; - BMesh *prev_select_bm = NULL; - - static struct { - int index; - const BMFace *elem; - const BMesh *bm; - } prev_select = {0}; - - data.mval_fl[0] = vc->mval[0]; - data.mval_fl[1] = vc->mval[1]; - data.use_select_bias = use_select_bias; - data.use_cycle = use_cycle; - - for (; base_index < bases_len; base_index++) { - Base *base_iter = bases[base_index]; - ED_view3d_viewcontext_init_object(vc, base_iter->object); - if (use_cycle && prev_select.bm == vc->em->bm && - prev_select.elem == BM_face_at_index_find_or_table(vc->em->bm, prev_select.index)) { - data.cycle_index_prev = prev_select.index; - /* No need to compare in the rest of the loop. */ - use_cycle = false; - } - else { - data.cycle_index_prev = 0; - } - data.hit.dist = data.hit_cycle.dist = data.hit.dist_bias = data.hit_cycle.dist_bias = - *r_dist; + struct NearestFaceUserData data = {{0}}; + const struct NearestFaceUserData_Hit *hit = NULL; + const eV3DProjTest clip_flag = V3D_PROJ_TEST_CLIP_DEFAULT; + BMesh *prev_select_bm = NULL; - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - mesh_foreachScreenFace(vc, findnearestface__doClosest, &data, clip_flag); + static struct { + int index; + const BMFace *elem; + const BMesh *bm; + } prev_select = {0}; - hit = (data.use_cycle && data.hit_cycle.face) ? &data.hit_cycle : &data.hit; + data.mval_fl[0] = vc->mval[0]; + data.mval_fl[1] = vc->mval[1]; + data.use_select_bias = use_select_bias; + data.use_cycle = use_cycle; - if (hit->dist < *r_dist) { - if (r_base_index) { - *r_base_index = base_index; - } - *r_dist = hit->dist; - prev_select_bm = vc->em->bm; - } + for (; base_index < bases_len; base_index++) { + Base *base_iter = bases[base_index]; + ED_view3d_viewcontext_init_object(vc, base_iter->object); + if (use_cycle && prev_select.bm == vc->em->bm && + prev_select.elem == BM_face_at_index_find_or_table(vc->em->bm, prev_select.index)) { + data.cycle_index_prev = prev_select.index; + /* No need to compare in the rest of the loop. */ + use_cycle = false; } - - if (hit == NULL) { - return NULL; + else { + data.cycle_index_prev = 0; } - if (r_dist_center) { - *r_dist_center = hit->dist; + data.hit.dist = data.hit_cycle.dist = data.hit.dist_bias = data.hit_cycle.dist_bias = *r_dist; + + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); + mesh_foreachScreenFace(vc, findnearestface__doClosest, &data, clip_flag); + + hit = (data.use_cycle && data.hit_cycle.face) ? &data.hit_cycle : &data.hit; + + if (hit->dist < *r_dist) { + if (r_base_index) { + *r_base_index = base_index; + } + *r_dist = hit->dist; + prev_select_bm = vc->em->bm; } + } - prev_select.index = hit->index; - prev_select.elem = hit->face; - prev_select.bm = prev_select_bm; + if (hit == NULL) { + return NULL; + } - return hit->face; + if (r_dist_center) { + *r_dist_center = hit->dist; } + + prev_select.index = hit->index; + prev_select.elem = hit->face; + prev_select.bm = prev_select_bm; + + return hit->face; } BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist) @@ -1353,9 +1347,7 @@ static int edbm_select_mode_exec(bContext *C, wmOperator *op) if (EDBM_selectmode_toggle_multi(C, type, action, use_extend, use_expand)) { return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } static int edbm_select_mode_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -1809,9 +1801,7 @@ static int edbm_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *e RNA_boolean_get(op->ptr, "ring"))) { return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } void MESH_OT_loop_select(wmOperatorType *ot) @@ -2556,9 +2546,7 @@ bool EDBM_selectmode_disable(Scene *scene, return true; } - else { - return false; - } + return false; } /** \} */ @@ -4202,11 +4190,11 @@ static bool edbm_deselect_nth(BMEditMesh *em, const struct CheckerIntervalParams walker_deselect_nth(em, op_params, &v->head); return true; } - else if (e) { + if (e) { walker_deselect_nth(em, op_params, &e->head); return true; } - else if (f) { + if (f) { walker_deselect_nth(em, op_params, &f->head); return true; } diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c index 635fc6279ea..b3fb9747070 100644 --- a/source/blender/editors/mesh/editmesh_select_similar.c +++ b/source/blender/editors/mesh/editmesh_select_similar.c @@ -245,9 +245,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) if (custom_data_offset == -1) { continue; } - else { - gset_array[ob_index] = BLI_gset_ptr_new("Select similar face: facemap gset"); - } + gset_array[ob_index] = BLI_gset_ptr_new("Select similar face: facemap gset"); } } @@ -1249,12 +1247,10 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op) if (type < 100) { return similar_vert_select_exec(C, op); } - else if (type < 200) { + if (type < 200) { return similar_edge_select_exec(C, op); } - else { - return similar_face_select_exec(C, op); - } + return similar_face_select_exec(C, op); } static const EnumPropertyItem *select_similar_type_itemf(bContext *C, diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 2cffb3ecdec..9907a124ba6 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -1557,7 +1557,7 @@ static int edbm_vert_connect_path_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Invalid selection order"); return OPERATOR_CANCELLED; } - else if (failed_connect_len == objects_len) { + if (failed_connect_len == objects_len) { BKE_report(op->reports, RPT_ERROR, "Could not connect vertices"); return OPERATOR_CANCELLED; } @@ -2686,7 +2686,7 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "No selected vertex"); return OPERATOR_CANCELLED; } - else if (tot_invalid == objects_len) { + if (tot_invalid == objects_len) { BKE_report(op->reports, RPT_WARNING, "Selected faces must be triangles or quads"); return OPERATOR_CANCELLED; } @@ -3505,7 +3505,7 @@ static int edbm_shape_propagate_to_all_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No selected vertex"); return OPERATOR_CANCELLED; } - else if (tot_shapekeys == 0) { + if (tot_shapekeys == 0) { BKE_report(op->reports, RPT_ERROR, objects_len > 1 ? "Meshes do not have shape keys" : @@ -3562,7 +3562,7 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Active mesh does not have shape keys"); return OPERATOR_CANCELLED; } - else if (shape_ref >= totshape_ref) { + if (shape_ref >= totshape_ref) { /* This case occurs if operator was used before on object with more keys than current one. */ shape_ref = 0; /* default to basis */ } @@ -3592,10 +3592,8 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op) if (!key) { continue; } - else { - kb = BKE_keyblock_find_name(key, kb_ref->name); - shape = BLI_findindex(&key->block, kb); - } + kb = BKE_keyblock_find_name(key, kb_ref->name); + shape = BLI_findindex(&key->block, kb); if (kb) { /* Perform blending on selected vertices. */ @@ -3861,7 +3859,7 @@ static float bm_edge_seg_isect(const float sco_a[2], return perc; } /* test e->v2 */ - else if ((x11 == x22 && y11 == y22) || (x12 == x22 && y12 == y22)) { + if ((x11 == x22 && y11 == y22) || (x12 == x22 && y12 == y22)) { perc = 0; *isected = 2; return perc; @@ -5885,12 +5883,10 @@ static int edbm_dissolve_mode_exec(bContext *C, wmOperator *op) if (em->selectmode & SCE_SELECT_VERTEX) { return edbm_dissolve_verts_exec(C, op); } - else if (em->selectmode & SCE_SELECT_EDGE) { + if (em->selectmode & SCE_SELECT_EDGE) { return edbm_dissolve_edges_exec(C, op); } - else { - return edbm_dissolve_faces_exec(C, op); - } + return edbm_dissolve_faces_exec(C, op); } void MESH_OT_dissolve_mode(wmOperatorType *ot) @@ -6814,9 +6810,7 @@ static bool edbm_sort_elements_poll_property(const bContext *UNUSED(C), if (action == SRT_RANDOMIZE) { return true; } - else { - return false; - } + return false; } /* Hide seed for reverse and randomize actions! */ @@ -6824,9 +6818,7 @@ static bool edbm_sort_elements_poll_property(const bContext *UNUSED(C), if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE)) { return false; } - else { - return true; - } + return true; } return true; @@ -7507,10 +7499,8 @@ static int mesh_symmetrize_exec(bContext *C, wmOperator *op) if (!EDBM_op_finish(em, &bmop, op, true)) { continue; } - else { - EDBM_update_generic(obedit->data, true, true); - EDBM_selectmode_flush(em); - } + EDBM_update_generic(obedit->data, true, true); + EDBM_selectmode_flush(em); } MEM_freeN(objects); @@ -8869,7 +8859,7 @@ static bool average_normals_draw_check_prop(PointerRNA *ptr, if (STREQ(prop_id, "weight")) { return (average_type == EDBM_CLNOR_AVERAGE_LOOP); } - else if (STREQ(prop_id, "threshold")) { + if (STREQ(prop_id, "threshold")) { return (average_type == EDBM_CLNOR_AVERAGE_LOOP); } diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 6c9973dc209..b60e0074512 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -187,20 +187,19 @@ bool EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const bool return false; } - else { - em->emcopyusers--; - if (em->emcopyusers < 0) { - printf("warning: em->emcopyusers was less than zero.\n"); - } - if (em->emcopyusers <= 0) { - BKE_editmesh_free(em->emcopy); - MEM_freeN(em->emcopy); - em->emcopy = NULL; - } + em->emcopyusers--; + if (em->emcopyusers < 0) { + printf("warning: em->emcopyusers was less than zero.\n"); + } - return true; + if (em->emcopyusers <= 0) { + BKE_editmesh_free(em->emcopy); + MEM_freeN(em->emcopy); + em->emcopy = NULL; } + + return true; } bool EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt, ...) @@ -1628,10 +1627,10 @@ bool BMBVH_EdgeVisible(struct BMBVHTree *tree, if (f && !edge_ray_cast(tree, co2, dir2, NULL, e)) { return true; } - else if (f && !edge_ray_cast(tree, co3, dir3, NULL, e)) { + if (f && !edge_ray_cast(tree, co3, dir3, NULL, e)) { return true; } - else if (!f) { + if (!f) { return true; } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 8fce726eff5..f608e5ce6a5 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -370,9 +370,7 @@ bool ED_mesh_uv_texture_remove_active(Mesh *me) if (n != -1) { return ED_mesh_uv_texture_remove_index(me, n); } - else { - return false; - } + return false; } bool ED_mesh_uv_texture_remove_named(Mesh *me, const char *name) { @@ -382,9 +380,7 @@ bool ED_mesh_uv_texture_remove_named(Mesh *me, const char *name) if (n != -1) { return ED_mesh_uv_texture_remove_index(me, n); } - else { - return false; - } + return false; } /* note: keep in sync with ED_mesh_uv_texture_add */ @@ -479,9 +475,7 @@ bool ED_mesh_color_remove_active(Mesh *me) if (n != -1) { return ED_mesh_color_remove_index(me, n); } - else { - return false; - } + return false; } bool ED_mesh_color_remove_named(Mesh *me, const char *name) { @@ -490,9 +484,7 @@ bool ED_mesh_color_remove_named(Mesh *me, const char *name) if (n != -1) { return ED_mesh_color_remove_index(me, n); } - else { - return false; - } + return false; } /*********************** Sculpt Vertex colors operators ************************/ @@ -590,9 +582,7 @@ bool ED_mesh_sculpt_color_remove_active(Mesh *me) if (n != -1) { return ED_mesh_sculpt_color_remove_index(me, n); } - else { - return false; - } + return false; } bool ED_mesh_sculpt_color_remove_named(Mesh *me, const char *name) { @@ -601,9 +591,7 @@ bool ED_mesh_sculpt_color_remove_named(Mesh *me, const char *name) if (n != -1) { return ED_mesh_sculpt_color_remove_index(me, n); } - else { - return false; - } + return false; } /*********************** UV texture operators ************************/ @@ -817,9 +805,7 @@ static int mesh_customdata_clear_exec__internal(bContext *C, char htype, int typ return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } /* Clear Mask */ @@ -855,9 +841,7 @@ static int mesh_customdata_mask_clear_exec(bContext *C, wmOperator *UNUSED(op)) if (ret_a == OPERATOR_FINISHED || ret_b == OPERATOR_FINISHED) { return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } void MESH_OT_customdata_mask_clear(wmOperatorType *ot) @@ -1289,7 +1273,7 @@ void ED_mesh_verts_remove(Mesh *mesh, ReportList *reports, int count) BKE_report(reports, RPT_ERROR, "Cannot remove vertices in edit mode"); return; } - else if (count > mesh->totvert) { + if (count > mesh->totvert) { BKE_report(reports, RPT_ERROR, "Cannot remove more vertices than the mesh contains"); return; } @@ -1303,7 +1287,7 @@ void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count) BKE_report(reports, RPT_ERROR, "Cannot remove edges in edit mode"); return; } - else if (count > mesh->totedge) { + if (count > mesh->totedge) { BKE_report(reports, RPT_ERROR, "Cannot remove more edges than the mesh contains"); return; } @@ -1317,7 +1301,7 @@ void ED_mesh_loops_remove(Mesh *mesh, ReportList *reports, int count) BKE_report(reports, RPT_ERROR, "Cannot remove loops in edit mode"); return; } - else if (count > mesh->totloop) { + if (count > mesh->totloop) { BKE_report(reports, RPT_ERROR, "Cannot remove more loops than the mesh contains"); return; } @@ -1331,7 +1315,7 @@ void ED_mesh_polys_remove(Mesh *mesh, ReportList *reports, int count) BKE_report(reports, RPT_ERROR, "Cannot remove polys in edit mode"); return; } - else if (count > mesh->totpoly) { + if (count > mesh->totpoly) { BKE_report(reports, RPT_ERROR, "Cannot remove more polys than the mesh contains"); return; } diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c index 0bbc8b0df76..0f746dfd3a0 100644 --- a/source/blender/editors/mesh/mesh_mirror.c +++ b/source/blender/editors/mesh/mesh_mirror.c @@ -129,7 +129,7 @@ static int mirrtopo_hash_sort(const void *l1, const void *l2) if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2) { return 1; } - else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2) { + if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2) { return -1; } return 0; @@ -140,7 +140,7 @@ static int mirrtopo_vert_sort(const void *v1, const void *v2) if (((MirrTopoVert_t *)v1)->hash > ((MirrTopoVert_t *)v2)->hash) { return 1; } - else if (((MirrTopoVert_t *)v1)->hash < ((MirrTopoVert_t *)v2)->hash) { + if (((MirrTopoVert_t *)v1)->hash < ((MirrTopoVert_t *)v2)->hash) { return -1; } return 0; @@ -166,9 +166,7 @@ bool ED_mesh_mirrtopo_recalc_check(BMEditMesh *em, Mesh *me, MirrTopoStore_t *me (totvert != mesh_topo_store->prev_vert_tot) || (totedge != mesh_topo_store->prev_edge_tot)) { return true; } - else { - return false; - } + return false; } void ED_mesh_mirrtopo_init(BMEditMesh *em, @@ -278,10 +276,8 @@ void ED_mesh_mirrtopo_init(BMEditMesh *em, * higher number of unique values compared to the previous loop. */ break; } - else { - tot_unique_prev = tot_unique; - tot_unique_edges_prev = tot_unique_edges; - } + tot_unique_prev = tot_unique; + tot_unique_edges_prev = tot_unique_edges; /* Copy the hash calculated this iteration, so we can use them next time */ memcpy(topo_hash_prev, topo_hash, sizeof(MirrTopoHash_t) * totvert); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 1bdf2ede22a..b0730b32bed 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -892,9 +892,7 @@ int mesh_get_x_mirror_vert(Object *ob, Mesh *me_eval, int index, const bool use_ if (use_topology) { return mesh_get_x_mirror_vert_topo(ob, me_eval, index); } - else { - return mesh_get_x_mirror_vert_spatial(ob, me_eval, index); - } + return mesh_get_x_mirror_vert_spatial(ob, me_eval, index); } static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, const float co[3]) @@ -963,9 +961,7 @@ BMVert *editbmesh_get_x_mirror_vert(Object *ob, if (use_topology) { return editbmesh_get_x_mirror_vert_topo(ob, em, eve, index); } - else { - return editbmesh_get_x_mirror_vert_spatial(ob, em, co); - } + return editbmesh_get_x_mirror_vert_spatial(ob, em, co); } /** @@ -1072,13 +1068,13 @@ static int mirror_facerotation(MFace *a, MFace *b) if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3 && a->v4 == b->v4) { return 0; } - else if (a->v4 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3 && a->v3 == b->v4) { + if (a->v4 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3 && a->v3 == b->v4) { return 1; } - else if (a->v3 == b->v1 && a->v4 == b->v2 && a->v1 == b->v3 && a->v2 == b->v4) { + if (a->v3 == b->v1 && a->v4 == b->v2 && a->v1 == b->v3 && a->v2 == b->v4) { return 2; } - else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v4 == b->v3 && a->v1 == b->v4) { + if (a->v2 == b->v1 && a->v3 == b->v2 && a->v4 == b->v3 && a->v1 == b->v4) { return 3; } } @@ -1086,10 +1082,10 @@ static int mirror_facerotation(MFace *a, MFace *b) if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3) { return 0; } - else if (a->v3 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3) { + if (a->v3 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3) { return 1; } - else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3) { + if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3) { return 2; } } @@ -1468,9 +1464,7 @@ MDeformVert *ED_mesh_active_dvert_get_ob(Object *ob, int *r_index) if (index == -1 || me->dvert == NULL) { return NULL; } - else { - return me->dvert + index; - } + return me->dvert + index; } MDeformVert *ED_mesh_active_dvert_get_only(Object *ob) @@ -1479,13 +1473,9 @@ MDeformVert *ED_mesh_active_dvert_get_only(Object *ob) if (ob->mode & OB_MODE_EDIT) { return ED_mesh_active_dvert_get_em(ob, NULL); } - else { - return ED_mesh_active_dvert_get_ob(ob, NULL); - } - } - else { - return NULL; + return ED_mesh_active_dvert_get_ob(ob, NULL); } + return NULL; } void EDBM_mesh_stats_multi(struct Object **objects, -- cgit v1.2.3