diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-07-03 17:09:51 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-07-03 17:15:01 +0300 |
commit | 2a39b34a09702e4e64e27befc97dd6154b75ccc0 (patch) | |
tree | 1a4cfc24b941dee5895b2dbd388c9cc453a31ce3 /source/blender/editors/sculpt_paint/paint_image_proj.c | |
parent | fd5b093f84845ab7adbe7e6e4dec4bbadbbc16af (diff) |
Cleanup: Editors/Sculpt/Paint, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/sculpt_paint` module.
No functional changes.
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_image_proj.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 263 |
1 files changed, 120 insertions, 143 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index a15d7a732f1..83620b4bc56 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -557,12 +557,11 @@ static Image *project_paint_face_paint_image(const ProjPaintState *ps, int tri_i if (ps->do_stencil_brush) { return ps->stencil_ima; } - else { - const MPoly *mp = ps_tri_index_to_mpoly(ps, tri_index); - Material *ma = ps->mat_array[mp->mat_nr]; - TexPaintSlot *slot = ma ? ma->texpaintslot + ma->paint_active_slot : NULL; - return slot ? slot->ima : ps->canvas_ima; - } + + const MPoly *mp = ps_tri_index_to_mpoly(ps, tri_index); + Material *ma = ps->mat_array[mp->mat_nr]; + TexPaintSlot *slot = ma ? ma->texpaintslot + ma->paint_active_slot : NULL; + return slot ? slot->ima : ps->canvas_ima; } static TexPaintSlot *project_paint_face_clone_slot(const ProjPaintState *ps, int tri_index) @@ -605,9 +604,7 @@ static int project_bucket_offset_safe(const ProjPaintState *ps, const float proj if (bucket_index < 0 || bucket_index >= ps->buckets_x * ps->buckets_y) { return -1; } - else { - return bucket_index; - } + return bucket_index; } static float VecZDepthOrtho( @@ -840,18 +837,17 @@ static int project_paint_occlude_ptv(const float pt[3], if (v1[2] < pt[2] && v2[2] < pt[2] && v3[2] < pt[2]) { return 1; } - else { - /* we intersect? - find the exact depth at the point of intersection */ - /* Is this point is occluded by another face? */ - if (is_ortho) { - if (VecZDepthOrtho(pt, v1, v2, v3, w) < pt[2]) { - return 2; - } + + /* we intersect? - find the exact depth at the point of intersection */ + /* Is this point is occluded by another face? */ + if (is_ortho) { + if (VecZDepthOrtho(pt, v1, v2, v3, w) < pt[2]) { + return 2; } - else { - if (VecZDepthPersp(pt, v1, v2, v3, w) < pt[2]) { - return 2; - } + } + else { + if (VecZDepthPersp(pt, v1, v2, v3, w) < pt[2]) { + return 2; } } return -1; @@ -977,14 +973,12 @@ static int line_isect_y(const float p1[2], const float p2[2], const float y_leve *x_isect = (p2[0] * (p1[1] - y_level) + p1[0] * (y_level - p2[1])) / y_diff; return ISECT_TRUE; } - else if (p1[1] < y_level && p2[1] > y_level) { + if (p1[1] < y_level && p2[1] > y_level) { /* (p2[1] - p1[1]); */ *x_isect = (p2[0] * (y_level - p1[1]) + p1[0] * (p2[1] - y_level)) / y_diff; return ISECT_TRUE; } - else { - return 0; - } + return 0; } static int line_isect_x(const float p1[2], const float p2[2], const float x_level, float *y_isect) @@ -1014,14 +1008,12 @@ static int line_isect_x(const float p1[2], const float p2[2], const float x_leve *y_isect = (p2[1] * (p1[0] - x_level) + p1[1] * (x_level - p2[0])) / x_diff; return ISECT_TRUE; } - else if (p1[0] < x_level && p2[0] > x_level) { + if (p1[0] < x_level && p2[0] > x_level) { /* (p2[0] - p1[0]); */ *y_isect = (p2[1] * (x_level - p1[0]) + p1[1] * (p2[0] - x_level)) / x_diff; return ISECT_TRUE; } - else { - return 0; - } + return 0; } /* simple func use for comparing UV locations to check if there are seams. @@ -1204,10 +1196,8 @@ static bool check_seam(const ProjPaintState *ps, // printf("SEAM (NONE)\n"); return false; } - else { - // printf("SEAM (UV GAP)\n"); - return true; - } + // printf("SEAM (UV GAP)\n"); + return true; } } } @@ -1788,7 +1778,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps, /* outsize the normal limit*/ return 0.0f; } - else if (angle_cos < ps->normal_angle_inner__cos) { + if (angle_cos < ps->normal_angle_inner__cos) { mask *= (ps->normal_angle - acosf(angle_cos)) / ps->normal_angle_range; } /* otherwise no mask normal is needed, we're within the limit */ } @@ -1805,9 +1795,7 @@ static int project_paint_pixel_sizeof(const short tool) if ((tool == PAINT_TOOL_CLONE) || (tool == PAINT_TOOL_SMEAR)) { return sizeof(ProjPixelClone); } - else { - return sizeof(ProjPixel); - } + return sizeof(ProjPixel); } static int project_paint_undo_subtiles(const TileInfo *tinf, int tx, int ty) @@ -2083,9 +2071,7 @@ static bool line_clip_rect2f(const rctf *cliprect, copy_v2_v2(l2_clip, l2); return true; } - else { - return false; - } + return false; } copy_v2_v2(l1_clip, l1); @@ -2094,7 +2080,7 @@ static bool line_clip_rect2f(const rctf *cliprect, CLAMP(l2_clip[0], rect->xmin, rect->xmax); return true; } - else if (fabsf(l1[0] - l2[0]) < PROJ_PIXEL_TOLERANCE) { + if (fabsf(l1[0] - l2[0]) < PROJ_PIXEL_TOLERANCE) { /* is the line out of range on its X axis? */ if (l1[0] < rect->xmin || l1[0] > rect->xmax) { return 0; @@ -2112,9 +2098,7 @@ static bool line_clip_rect2f(const rctf *cliprect, copy_v2_v2(l2_clip, l2); return true; } - else { - return false; - } + return false; } copy_v2_v2(l1_clip, l1); @@ -2123,106 +2107,103 @@ static bool line_clip_rect2f(const rctf *cliprect, CLAMP(l2_clip[1], rect->ymin, rect->ymax); return true; } - else { - float isect; - short ok1 = 0; - short ok2 = 0; - /* Done with vertical lines */ + float isect; + short ok1 = 0; + short ok2 = 0; - /* are either of the points inside the rectangle ? */ - if (BLI_rctf_isect_pt_v(rect, l1)) { - copy_v2_v2(l1_clip, l1); - ok1 = 1; - } + /* Done with vertical lines */ - if (BLI_rctf_isect_pt_v(rect, l2)) { - copy_v2_v2(l2_clip, l2); - ok2 = 1; - } + /* are either of the points inside the rectangle ? */ + if (BLI_rctf_isect_pt_v(rect, l1)) { + copy_v2_v2(l1_clip, l1); + ok1 = 1; + } - /* line inside rect */ - if (ok1 && ok2) { - return 1; - } + if (BLI_rctf_isect_pt_v(rect, l2)) { + copy_v2_v2(l2_clip, l2); + ok2 = 1; + } - /* top/bottom */ - if (line_isect_y(l1, l2, rect->ymin, &isect) && (isect >= cliprect->xmin) && - (isect <= cliprect->xmax)) { - if (l1[1] < l2[1]) { /* line 1 is outside */ - l1_clip[0] = isect; - l1_clip[1] = rect->ymin; - ok1 = 1; - } - else { - l2_clip[0] = isect; - l2_clip[1] = rect->ymin; - ok2 = 2; - } - } + /* line inside rect */ + if (ok1 && ok2) { + return 1; + } - if (ok1 && ok2) { - return true; + /* top/bottom */ + if (line_isect_y(l1, l2, rect->ymin, &isect) && (isect >= cliprect->xmin) && + (isect <= cliprect->xmax)) { + if (l1[1] < l2[1]) { /* line 1 is outside */ + l1_clip[0] = isect; + l1_clip[1] = rect->ymin; + ok1 = 1; } - - if (line_isect_y(l1, l2, rect->ymax, &isect) && (isect >= cliprect->xmin) && - (isect <= cliprect->xmax)) { - if (l1[1] > l2[1]) { /* line 1 is outside */ - l1_clip[0] = isect; - l1_clip[1] = rect->ymax; - ok1 = 1; - } - else { - l2_clip[0] = isect; - l2_clip[1] = rect->ymax; - ok2 = 2; - } + else { + l2_clip[0] = isect; + l2_clip[1] = rect->ymin; + ok2 = 2; } + } - if (ok1 && ok2) { - return true; - } + if (ok1 && ok2) { + return true; + } - /* left/right */ - if (line_isect_x(l1, l2, rect->xmin, &isect) && (isect >= cliprect->ymin) && - (isect <= cliprect->ymax)) { - if (l1[0] < l2[0]) { /* line 1 is outside */ - l1_clip[0] = rect->xmin; - l1_clip[1] = isect; - ok1 = 1; - } - else { - l2_clip[0] = rect->xmin; - l2_clip[1] = isect; - ok2 = 2; - } + if (line_isect_y(l1, l2, rect->ymax, &isect) && (isect >= cliprect->xmin) && + (isect <= cliprect->xmax)) { + if (l1[1] > l2[1]) { /* line 1 is outside */ + l1_clip[0] = isect; + l1_clip[1] = rect->ymax; + ok1 = 1; } - - if (ok1 && ok2) { - return true; + else { + l2_clip[0] = isect; + l2_clip[1] = rect->ymax; + ok2 = 2; } + } - if (line_isect_x(l1, l2, rect->xmax, &isect) && (isect >= cliprect->ymin) && - (isect <= cliprect->ymax)) { - if (l1[0] > l2[0]) { /* line 1 is outside */ - l1_clip[0] = rect->xmax; - l1_clip[1] = isect; - ok1 = 1; - } - else { - l2_clip[0] = rect->xmax; - l2_clip[1] = isect; - ok2 = 2; - } + if (ok1 && ok2) { + return true; + } + + /* left/right */ + if (line_isect_x(l1, l2, rect->xmin, &isect) && (isect >= cliprect->ymin) && + (isect <= cliprect->ymax)) { + if (l1[0] < l2[0]) { /* line 1 is outside */ + l1_clip[0] = rect->xmin; + l1_clip[1] = isect; + ok1 = 1; } + else { + l2_clip[0] = rect->xmin; + l2_clip[1] = isect; + ok2 = 2; + } + } - if (ok1 && ok2) { - return true; + if (ok1 && ok2) { + return true; + } + + if (line_isect_x(l1, l2, rect->xmax, &isect) && (isect >= cliprect->ymin) && + (isect <= cliprect->ymax)) { + if (l1[0] > l2[0]) { /* line 1 is outside */ + l1_clip[0] = rect->xmax; + l1_clip[1] = isect; + ok1 = 1; } else { - return false; + l2_clip[0] = rect->xmax; + l2_clip[1] = isect; + ok2 = 2; } } + + if (ok1 && ok2) { + return true; + } + return false; } /** @@ -2299,7 +2280,7 @@ static bool project_bucket_isect_circle(const float cent[2], false; } /* top left test */ - else if (cent[1] > bucket_bounds->ymax) { + if (cent[1] > bucket_bounds->ymax) { return (len_squared_v2v2_alt(cent, bucket_bounds->xmin, bucket_bounds->ymax) < radius_squared) ? true : @@ -2315,7 +2296,7 @@ static bool project_bucket_isect_circle(const float cent[2], false; } /* top right test */ - else if (cent[1] > bucket_bounds->ymax) { + if (cent[1] > bucket_bounds->ymax) { return (len_squared_v2v2_alt(cent, bucket_bounds->xmax, bucket_bounds->ymax) < radius_squared) ? true : @@ -2670,7 +2651,8 @@ static void project_bucket_clip_face(const bool is_ortho, *tot = 4; return; } - else { + + { /* The Complicated Case! * * The 2 cases above are where the face is inside the bucket @@ -4209,9 +4191,7 @@ static bool project_paint_check_face_sel(const ProjPaintState *ps, return ((mp->flag & ME_FACE_SEL) != 0); } - else { - return true; - } + return true; } typedef struct { @@ -6144,19 +6124,18 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Could not get valid evaluated mesh"); return OPERATOR_CANCELLED; } - else { - float pos[2] = {0.0, 0.0}; - float lastpos[2] = {0.0, 0.0}; - int a; - project_paint_op(&ps, lastpos, pos); + float pos[2] = {0.0, 0.0}; + float lastpos[2] = {0.0, 0.0}; + int a; - project_image_refresh_tagged(&ps); + project_paint_op(&ps, lastpos, pos); - for (a = 0; a < ps.image_tot; a++) { - GPU_free_image(ps.projImages[a].ima); - WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ps.projImages[a].ima); - } + project_image_refresh_tagged(&ps); + + for (a = 0; a < ps.image_tot; a++) { + GPU_free_image(ps.projImages[a].ima); + WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ps.projImages[a].ima); } project_paint_end(&ps); @@ -6697,9 +6676,7 @@ static int texture_paint_add_texture_paint_slot_exec(bContext *C, wmOperator *op if (proj_paint_add_slot(C, op)) { return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } static void get_default_texture_layer_name_for_object(Object *ob, |