Style: Enforce braces around if blocks and loops

Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
This commit is contained in:
Rémi Verschelde
2020-05-14 16:41:43 +02:00
parent 07bc4e2f96
commit 0ee0fa42e6
683 changed files with 22803 additions and 12225 deletions

View File

@@ -48,16 +48,18 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2
real_t csign;
if (seg_from < seg_to) {
if (seg_from > box_end || seg_to < box_begin)
if (seg_from > box_end || seg_to < box_begin) {
return false;
}
real_t length = seg_to - seg_from;
cmin = (seg_from < box_begin) ? ((box_begin - seg_from) / length) : 0;
cmax = (seg_to > box_end) ? ((box_end - seg_from) / length) : 1;
csign = -1.0;
} else {
if (seg_to > box_end || seg_from < box_begin)
if (seg_to > box_end || seg_from < box_begin) {
return false;
}
real_t length = seg_to - seg_from;
cmin = (seg_from > box_end) ? (box_end - seg_from) / length : 0;
cmax = (seg_to < box_begin) ? (box_begin - seg_from) / length : 1;
@@ -69,10 +71,12 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2
axis = i;
sign = csign;
}
if (cmax < max)
if (cmax < max) {
max = cmax;
if (max < min)
}
if (max < min) {
return false;
}
}
Vector2 rel = p_to - p_from;
@@ -83,8 +87,9 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2
*r_normal = normal;
}
if (r_pos)
if (r_pos) {
*r_pos = p_from + rel * min;
}
return true;
}
@@ -103,14 +108,18 @@ bool Rect2::intersects_transformed(const Transform2D &p_xform, const Rect2 &p_re
//base rect2 first (faster)
if (xf_points[0].y > position.y)
if (xf_points[0].y > position.y) {
goto next1;
if (xf_points[1].y > position.y)
}
if (xf_points[1].y > position.y) {
goto next1;
if (xf_points[2].y > position.y)
}
if (xf_points[2].y > position.y) {
goto next1;
if (xf_points[3].y > position.y)
}
if (xf_points[3].y > position.y) {
goto next1;
}
return false;
@@ -118,27 +127,35 @@ next1:
low_limit = position.y + size.y;
if (xf_points[0].y < low_limit)
if (xf_points[0].y < low_limit) {
goto next2;
if (xf_points[1].y < low_limit)
}
if (xf_points[1].y < low_limit) {
goto next2;
if (xf_points[2].y < low_limit)
}
if (xf_points[2].y < low_limit) {
goto next2;
if (xf_points[3].y < low_limit)
}
if (xf_points[3].y < low_limit) {
goto next2;
}
return false;
next2:
if (xf_points[0].x > position.x)
if (xf_points[0].x > position.x) {
goto next3;
if (xf_points[1].x > position.x)
}
if (xf_points[1].x > position.x) {
goto next3;
if (xf_points[2].x > position.x)
}
if (xf_points[2].x > position.x) {
goto next3;
if (xf_points[3].x > position.x)
}
if (xf_points[3].x > position.x) {
goto next3;
}
return false;
@@ -146,14 +163,18 @@ next3:
low_limit = position.x + size.x;
if (xf_points[0].x < low_limit)
if (xf_points[0].x < low_limit) {
goto next4;
if (xf_points[1].x < low_limit)
}
if (xf_points[1].x < low_limit) {
goto next4;
if (xf_points[2].x < low_limit)
}
if (xf_points[2].x < low_limit) {
goto next4;
if (xf_points[3].x < low_limit)
}
if (xf_points[3].x < low_limit) {
goto next4;
}
return false;
@@ -196,10 +217,12 @@ next4:
maxb = MAX(dp, maxb);
minb = MIN(dp, minb);
if (mina > maxb)
if (mina > maxb) {
return false;
if (minb > maxa)
}
if (minb > maxa) {
return false;
}
maxa = p_xform.elements[1].dot(xf_points2[0]);
mina = maxa;
@@ -231,10 +254,12 @@ next4:
maxb = MAX(dp, maxb);
minb = MIN(dp, minb);
if (mina > maxb)
if (mina > maxb) {
return false;
if (minb > maxa)
}
if (minb > maxa) {
return false;
}
return true;
}