[Bf-blender-cvs] [2a39b34a097] master: Cleanup: Editors/Sculpt/Paint, Clang-Tidy else-after-return fixes
Sybren A. Stüvel
noreply at git.blender.org
Fri Jul 3 16:15:13 CEST 2020
Commit: 2a39b34a09702e4e64e27befc97dd6154b75ccc0
Author: Sybren A. Stüvel
Date: Fri Jul 3 16:09:51 2020 +0200
Branches: master
https://developer.blender.org/rB2a39b34a09702e4e64e27befc97dd6154b75ccc0
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.
===================================================================
M source/blender/editors/sculpt_paint/paint_cursor.c
M source/blender/editors/sculpt_paint/paint_curve.c
M source/blender/editors/sculpt_paint/paint_hide.c
M source/blender/editors/sculpt_paint/paint_image_proj.c
M source/blender/editors/sculpt_paint/paint_ops.c
M source/blender/editors/sculpt_paint/paint_stroke.c
M source/blender/editors/sculpt_paint/paint_vertex.c
M source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
M source/blender/editors/sculpt_paint/paint_vertex_color_utils.c
M source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_automasking.c
M source/blender/editors/sculpt_paint/sculpt_cloth.c
M source/blender/editors/sculpt_paint/sculpt_pose.c
M source/blender/editors/sculpt_paint/sculpt_smooth.c
M source/blender/editors/sculpt_paint/sculpt_undo.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 909eae64e72..892aea6048f 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -557,11 +557,9 @@ static int project_brush_radius(ViewContext *vc, float radius, const float locat
/* The distance between these points is the size of the projected brush in pixels. */
return len_v2v2(p1, p2);
}
- else {
- /* Assert because the code that sets up the vectors should disallow this. */
- BLI_assert(0);
- return 0;
- }
+ /* Assert because the code that sets up the vectors should disallow this. */
+ BLI_assert(0);
+ return 0;
}
static bool sculpt_get_brush_geometry(bContext *C,
diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c
index 68fd2f15877..74e022bf84f 100644
--- a/source/blender/editors/sculpt_paint/paint_curve.c
+++ b/source/blender/editors/sculpt_paint/paint_curve.c
@@ -142,19 +142,15 @@ static char paintcurve_point_side_index(const BezTriple *bezt,
if ((bezt->f1 & SELECT) == (bezt->f3 & SELECT)) {
return is_first ? SEL_F1 : SEL_F3;
}
- else if (bezt->f1 & SELECT) {
+ if (bezt->f1 & SELECT) {
return SEL_F1;
}
- else if (bezt->f3 & SELECT) {
+ if (bezt->f3 & SELECT) {
return SEL_F3;
}
- else {
- return fallback;
- }
- }
- else {
- return 0;
+ return fallback;
}
+ return 0;
}
/******************* Operators *********************************/
@@ -491,9 +487,7 @@ static int paintcurve_select_point_invoke(bContext *C, wmOperator *op, const wmE
RNA_int_set_array(op->ptr, "location", loc);
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
static int paintcurve_select_point_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index e9dcc4a356a..339921fe601 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -70,13 +70,12 @@ static bool is_effected(PartialVisArea area,
if (area == PARTIALVIS_ALL) {
return true;
}
- else if (area == PARTIALVIS_MASKED) {
+ if (area == PARTIALVIS_MASKED) {
return mask > 0.5f;
}
- else {
- bool inside = isect_point_planes_v3(planes, 4, co);
- return ((inside && area == PARTIALVIS_INSIDE) || (!inside && area == PARTIALVIS_OUTSIDE));
- }
+
+ bool inside = isect_point_planes_v3(planes, 4, co);
+ return ((inside && area == PARTIALVIS_INSIDE) || (!inside && area == PARTIALVIS_OUTSIDE));
}
static void partialvis_update_mesh(Object *ob,
@@ -418,9 +417,7 @@ static int hide_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (!ELEM(area, PARTIALVIS_ALL, PARTIALVIS_MASKED)) {
return WM_gesture_box_invoke(C, op, event);
}
- else {
- return op->type->exec(C, op);
- }
+ return op->type->exec(C, op);
}
void PAINT_OT_hide_show(struct wmOperatorType *ot)
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) &&
- (isec
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list