diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-07-03 18:30:09 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-07-03 18:42:45 +0300 |
commit | 367034f210137754ab4f07a0e7793066d2b69e59 (patch) | |
tree | c3d00a054e8216c24180b7bf2db16c2366a3101c /source/blender/editors | |
parent | 651d1aa7c836892e95117e17716605a774c0220b (diff) |
Cleanup: Editors/Space/UV-Edit, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/uv_edit` module.
No functional changes.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_draw.c | 10 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_parametrizer.c | 52 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_select.c | 85 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_smart_stitch.c | 38 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_unwrap_ops.c | 4 |
6 files changed, 71 insertions, 122 deletions
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 28c55813a3b..c6b8b0cd02d 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -86,16 +86,12 @@ static int draw_uvs_face_check(const ToolSettings *ts) if (ts->selectmode == SCE_SELECT_FACE) { return 2; } - else if (ts->selectmode & SCE_SELECT_FACE) { + if (ts->selectmode & SCE_SELECT_FACE) { return 1; } - else { - return 0; - } - } - else { - return (ts->uv_selectmode == UV_SELECT_FACE); + return 0; } + return (ts->uv_selectmode == UV_SELECT_FACE); } /* ------------------------- */ diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 652d07f02db..8d85de3b141 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -998,9 +998,7 @@ static int uv_remove_doubles_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "use_unselected")) { return uv_remove_doubles_to_unselected(C, op); } - else { - return uv_remove_doubles_to_selected(C, op); - } + return uv_remove_doubles_to_selected(C, op); } static void UV_OT_remove_doubles(wmOperatorType *ot) diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index da8e0efa522..921b96f6023 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -321,7 +321,7 @@ static PHashLink *phash_lookup(PHash *ph, PHashKey key) if (link->key == key) { return link; } - else if (PHASH_hash(ph, link->key) != hash) { + if (PHASH_hash(ph, link->key) != hash) { return NULL; } } @@ -337,7 +337,7 @@ static PHashLink *phash_next(PHash *ph, PHashKey key, PHashLink *link) if (link->key == key) { return link; } - else if (PHASH_hash(ph, link->key) != hash) { + if (PHASH_hash(ph, link->key) != hash) { return NULL; } } @@ -372,12 +372,10 @@ static float p_vec_angle(const float v1[3], const float v2[3], const float v3[3] if (dot <= -1.0f) { return (float)M_PI; } - else if (dot >= 1.0f) { + if (dot >= 1.0f) { return 0.0f; } - else { - return acosf(dot); - } + return acosf(dot); } static float p_vec2_angle(const float v1[2], const float v2[2], const float v3[2]) @@ -790,9 +788,7 @@ static PVert *p_vert_lookup(PHandle *handle, PHashKey key, const float co[3], PE if (v) { return v; } - else { - return p_vert_add(handle, key, co, e); - } + return p_vert_add(handle, key, co, e); } static PVert *p_vert_copy(PChart *chart, PVert *v) @@ -818,7 +814,7 @@ static PEdge *p_edge_lookup(PHandle *handle, PHashKey *vkeys) if ((e->vert->u.key == vkeys[0]) && (e->next->vert->u.key == vkeys[1])) { return e; } - else if ((e->vert->u.key == vkeys[1]) && (e->next->vert->u.key == vkeys[0])) { + if ((e->vert->u.key == vkeys[1]) && (e->next->vert->u.key == vkeys[0])) { return e; } @@ -3353,11 +3349,10 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart) p_chart_lscm_load_solution(chart); return P_TRUE; } - else { - for (v = chart->verts; v; v = v->nextlink) { - v->uv[0] = 0.0f; - v->uv[1] = 0.0f; - } + + for (v = chart->verts; v; v = v->nextlink) { + v->uv[0] = 0.0f; + v->uv[1] = 0.0f; } return P_FALSE; @@ -3542,20 +3537,16 @@ static int p_compare_geometric_uv(const void *a, const void *b) if (v1->uv[0] < v2->uv[0]) { return -1; } - else if (v1->uv[0] == v2->uv[0]) { + if (v1->uv[0] == v2->uv[0]) { if (v1->uv[1] < v2->uv[1]) { return -1; } - else if (v1->uv[1] == v2->uv[1]) { + if (v1->uv[1] == v2->uv[1]) { return 0; } - else { - return 1; - } - } - else { return 1; } + return 1; } static PBool p_chart_convex_hull(PChart *chart, PVert ***r_verts, int *r_nverts, int *r_right) @@ -3935,14 +3926,11 @@ static PBool p_node_intersect(SmoothNode *node, float co[2]) return P_FALSE; } - else { - if (co[node->axis] < node->split) { - return p_node_intersect(node->c1, co); - } - else { - return p_node_intersect(node->c2, co); - } + + if (co[node->axis] < node->split) { + return p_node_intersect(node->c1, co); } + return p_node_intersect(node->c2, co); } /* smoothing */ @@ -3955,12 +3943,10 @@ static int p_compare_float(const void *a_, const void *b_) if (a < b) { return -1; } - else if (a == b) { + if (a == b) { return 0; } - else { - return 1; - } + return 1; } static float p_smooth_median_edge_length(PChart *chart) diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c index cc9be9d48c1..b701e94cd77 100644 --- a/source/blender/editors/uvedit/uvedit_select.c +++ b/source/blender/editors/uvedit/uvedit_select.c @@ -119,9 +119,7 @@ bool uvedit_face_visible_test_ex(const ToolSettings *ts, BMFace *efa) if (ts->uv_flag & UV_SYNC_SELECTION) { return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0); } - else { - return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0 && BM_elem_flag_test(efa, BM_ELEM_SELECT)); - } + return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0 && BM_elem_flag_test(efa, BM_ELEM_SELECT)); } bool uvedit_face_visible_test(const Scene *scene, BMFace *efa) { @@ -133,20 +131,18 @@ bool uvedit_face_select_test_ex(const ToolSettings *ts, BMFace *efa, const int c if (ts->uv_flag & UV_SYNC_SELECTION) { return (BM_elem_flag_test(efa, BM_ELEM_SELECT)); } - else { - BMLoop *l; - MLoopUV *luv; - BMIter liter; - BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - if (!(luv->flag & MLOOPUV_VERTSEL)) { - return false; - } - } + BMLoop *l; + MLoopUV *luv; + BMIter liter; - return true; + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { + luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + if (!(luv->flag & MLOOPUV_VERTSEL)) { + return false; + } } + return true; } bool uvedit_face_select_test(const Scene *scene, BMFace *efa, const int cd_loop_uv_offset) { @@ -163,9 +159,7 @@ bool uvedit_face_select_set(const struct Scene *scene, if (select) { return uvedit_face_select_enable(scene, em, efa, do_history, cd_loop_uv_offset); } - else { - return uvedit_face_select_disable(scene, em, efa, cd_loop_uv_offset); - } + return uvedit_face_select_disable(scene, em, efa, cd_loop_uv_offset); } bool uvedit_face_select_enable(const Scene *scene, @@ -230,22 +224,19 @@ bool uvedit_edge_select_test_ex(const ToolSettings *ts, BMLoop *l, const int cd_ if (ts->selectmode & SCE_SELECT_FACE) { return BM_elem_flag_test(l->f, BM_ELEM_SELECT); } - else if (ts->selectmode == SCE_SELECT_EDGE) { + if (ts->selectmode == SCE_SELECT_EDGE) { return BM_elem_flag_test(l->e, BM_ELEM_SELECT); } - else { - return BM_elem_flag_test(l->v, BM_ELEM_SELECT) && - BM_elem_flag_test(l->next->v, BM_ELEM_SELECT); - } + return BM_elem_flag_test(l->v, BM_ELEM_SELECT) && + BM_elem_flag_test(l->next->v, BM_ELEM_SELECT); } - else { - MLoopUV *luv1, *luv2; - luv1 = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - luv2 = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset); + MLoopUV *luv1, *luv2; - return (luv1->flag & MLOOPUV_VERTSEL) && (luv2->flag & MLOOPUV_VERTSEL); - } + luv1 = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + luv2 = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset); + + return (luv1->flag & MLOOPUV_VERTSEL) && (luv2->flag & MLOOPUV_VERTSEL); } bool uvedit_edge_select_test(const Scene *scene, BMLoop *l, const int cd_loop_uv_offset) { @@ -341,14 +332,11 @@ bool uvedit_uv_select_test_ex(const ToolSettings *ts, BMLoop *l, const int cd_lo if (ts->selectmode & SCE_SELECT_FACE) { return BM_elem_flag_test_bool(l->f, BM_ELEM_SELECT); } - else { - return BM_elem_flag_test_bool(l->v, BM_ELEM_SELECT); - } - } - else { - MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - return (luv->flag & MLOOPUV_VERTSEL) != 0; + return BM_elem_flag_test_bool(l->v, BM_ELEM_SELECT); } + + MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + return (luv->flag & MLOOPUV_VERTSEL) != 0; } bool uvedit_uv_select_test(const Scene *scene, BMLoop *l, const int cd_loop_uv_offset) { @@ -667,9 +655,7 @@ bool ED_uvedit_nearest_uv( *dist_sq = dist_best; return true; } - else { - return false; - } + return false; } bool ED_uvedit_nearest_uv_multi(const Scene *scene, @@ -1011,7 +997,7 @@ static void uv_select_linked_multi(Scene *scene, if ((startv != iterv) && (iterv->separate)) { break; } - else if (!flag[iterv->poly_index]) { + if (!flag[iterv->poly_index]) { flag[iterv->poly_index] = 1; stack[stacksize] = iterv->poly_index; stacksize++; @@ -1289,17 +1275,16 @@ bool uvedit_select_is_any_selected(Scene *scene, Object *obedit) if (ts->uv_flag & UV_SYNC_SELECTION) { return (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel); } - else { - const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - if (!uvedit_face_visible_test(scene, efa)) { - continue; - } - BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - if (luv->flag & MLOOPUV_VERTSEL) { - return true; - } + + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + if (!uvedit_face_visible_test(scene, efa)) { + continue; + } + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { + luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + if (luv->flag & MLOOPUV_VERTSEL) { + return true; } } } diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 594847b7249..38bd928e7b1 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -320,9 +320,7 @@ static int getNumOfIslandUvs(UvElementMap *elementMap, int island) if (island == elementMap->totalIslands - 1) { return elementMap->totalUVs - elementMap->islandIndices[island]; } - else { - return elementMap->islandIndices[island + 1] - elementMap->islandIndices[island]; - } + return elementMap->islandIndices[island + 1] - elementMap->islandIndices[island]; } static void stitch_uv_rotate(float mat[2][2], float medianPoint[2], float uv[2], float aspect) @@ -367,13 +365,9 @@ static bool stitch_check_uvs_stitchable(UvElement *element, fabsf(luv->uv[1] - luv_iter->uv[1]) < limit) { return 1; } - else { - return 0; - } - } - else { - return 1; + return 0; } + return 1; } static bool stitch_check_edges_stitchable(UvEdge *edge, @@ -411,13 +405,9 @@ static bool stitch_check_edges_stitchable(UvEdge *edge, fabsf(luv_orig2->uv[1] - luv_iter2->uv[1]) < limit) { return 1; } - else { - return 0; - } - } - else { - return 1; + return 0; } + return 1; } static bool stitch_check_uvs_state_stitchable(UvElement *element, @@ -2535,10 +2525,8 @@ static int stitch_exec(bContext *C, wmOperator *op) stitch_exit(C, op, 1); return OPERATOR_FINISHED; } - else { - stitch_cancel(C, op); - return OPERATOR_CANCELLED; - } + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } static StitchState *stitch_select(bContext *C, @@ -2619,14 +2607,12 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event) stitch_exit(C, op, 1); return OPERATOR_FINISHED; } - else { - stitch_cancel(C, op); - return OPERATOR_CANCELLED; - } - } - else { - return OPERATOR_PASS_THROUGH; + + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } + return OPERATOR_PASS_THROUGH; + /* Increase limit */ case EVT_PADPLUSKEY: case WHEELUPMOUSE: diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 3227a9557e6..aff73308fb5 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1981,9 +1981,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) if (changed_multi) { return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } static bool uv_from_view_poll(bContext *C) |