You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Style: clang-format: Disable AllowShortIfStatementsOnASingleLine
Part of #33027, also discussed in #29848. Enforcing the use of brackets even on single line statements would be preferred, but `clang-format` doesn't have this functionality yet.
This commit is contained in:
@@ -164,7 +164,8 @@ void AStar::connect_points(int p_id, int p_with_id, bool bidirectional) {
|
||||
}
|
||||
|
||||
Segment s(p_id, p_with_id);
|
||||
if (bidirectional) s.direction = Segment::BIDIRECTIONAL;
|
||||
if (bidirectional)
|
||||
s.direction = Segment::BIDIRECTIONAL;
|
||||
|
||||
Set<Segment>::Element *element = segments.find(s);
|
||||
if (element != nullptr) {
|
||||
@@ -290,7 +291,8 @@ int AStar::get_closest_point(const Vector3 &p_point, bool p_include_disabled) co
|
||||
|
||||
for (OAHashMap<int, Point *>::Iterator it = points.iter(); it.valid; it = points.next_iter(it)) {
|
||||
|
||||
if (!p_include_disabled && !(*it.value)->enabled) continue; // Disabled points should not be considered.
|
||||
if (!p_include_disabled && !(*it.value)->enabled)
|
||||
continue; // Disabled points should not be considered.
|
||||
|
||||
real_t d = p_point.distance_squared_to((*it.value)->pos);
|
||||
if (closest_id < 0 || d < closest_dist) {
|
||||
@@ -340,7 +342,8 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
|
||||
|
||||
pass++;
|
||||
|
||||
if (!end_point->enabled) return false;
|
||||
if (!end_point->enabled)
|
||||
return false;
|
||||
|
||||
bool found_route = false;
|
||||
|
||||
@@ -451,7 +454,8 @@ Vector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
|
||||
Point *end_point = b;
|
||||
|
||||
bool found_route = _solve(begin_point, end_point);
|
||||
if (!found_route) return Vector<Vector3>();
|
||||
if (!found_route)
|
||||
return Vector<Vector3>();
|
||||
|
||||
Point *p = end_point;
|
||||
int pc = 1; // Begin point
|
||||
@@ -499,7 +503,8 @@ Vector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
|
||||
Point *end_point = b;
|
||||
|
||||
bool found_route = _solve(begin_point, end_point);
|
||||
if (!found_route) return Vector<int>();
|
||||
if (!found_route)
|
||||
return Vector<int>();
|
||||
|
||||
Point *p = end_point;
|
||||
int pc = 1; // Begin point
|
||||
@@ -729,7 +734,8 @@ Vector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) {
|
||||
AStar::Point *end_point = b;
|
||||
|
||||
bool found_route = _solve(begin_point, end_point);
|
||||
if (!found_route) return Vector<Vector2>();
|
||||
if (!found_route)
|
||||
return Vector<Vector2>();
|
||||
|
||||
AStar::Point *p = end_point;
|
||||
int pc = 1; // Begin point
|
||||
@@ -777,7 +783,8 @@ Vector<int> AStar2D::get_id_path(int p_from_id, int p_to_id) {
|
||||
AStar::Point *end_point = b;
|
||||
|
||||
bool found_route = _solve(begin_point, end_point);
|
||||
if (!found_route) return Vector<int>();
|
||||
if (!found_route)
|
||||
return Vector<int>();
|
||||
|
||||
AStar::Point *p = end_point;
|
||||
int pc = 1; // Begin point
|
||||
@@ -809,7 +816,8 @@ bool AStar2D::_solve(AStar::Point *begin_point, AStar::Point *end_point) {
|
||||
|
||||
astar.pass++;
|
||||
|
||||
if (!end_point->enabled) return false;
|
||||
if (!end_point->enabled)
|
||||
return false;
|
||||
|
||||
bool found_route = false;
|
||||
|
||||
|
||||
@@ -783,7 +783,8 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
|
||||
real_t s = Math::sqrt((elements[1][2] - elements[2][1]) * (elements[1][2] - elements[2][1]) + (elements[2][0] - elements[0][2]) * (elements[2][0] - elements[0][2]) + (elements[0][1] - elements[1][0]) * (elements[0][1] - elements[1][0])); // s=|axis||sin(angle)|, used to normalise
|
||||
|
||||
angle = Math::acos((elements[0][0] + elements[1][1] + elements[2][2] - 1) / 2);
|
||||
if (angle < 0) s = -s;
|
||||
if (angle < 0)
|
||||
s = -s;
|
||||
x = (elements[2][1] - elements[1][2]) / s;
|
||||
y = (elements[0][2] - elements[2][0]) / s;
|
||||
z = (elements[1][0] - elements[0][1]) / s;
|
||||
|
||||
@@ -473,20 +473,23 @@ void CameraMatrix::invert() {
|
||||
|
||||
/** Divide column by minus pivot value **/
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (i != k) matrix[i][k] /= (-pvt_val);
|
||||
if (i != k)
|
||||
matrix[i][k] /= (-pvt_val);
|
||||
}
|
||||
|
||||
/** Reduce the matrix **/
|
||||
for (i = 0; i < 4; i++) {
|
||||
hold = matrix[i][k];
|
||||
for (j = 0; j < 4; j++) {
|
||||
if (i != k && j != k) matrix[i][j] += hold * matrix[k][j];
|
||||
if (i != k && j != k)
|
||||
matrix[i][j] += hold * matrix[k][j];
|
||||
}
|
||||
}
|
||||
|
||||
/** Divide row by pivot **/
|
||||
for (j = 0; j < 4; j++) {
|
||||
if (j != k) matrix[k][j] /= pvt_val;
|
||||
if (j != k)
|
||||
matrix[k][j] /= pvt_val;
|
||||
}
|
||||
|
||||
/** Replace pivot by reciprocal (at last we can touch it). **/
|
||||
|
||||
@@ -113,10 +113,14 @@ public:
|
||||
real_t mub = (d_of(p1, q1, q2, q1) + mua * d_of(q2, q1, p2, p1)) / d_of(q2, q1, q2, q1);
|
||||
|
||||
// Clip the value between [0..1] constraining the solution to lie on the original curves.
|
||||
if (mua < 0) mua = 0;
|
||||
if (mub < 0) mub = 0;
|
||||
if (mua > 1) mua = 1;
|
||||
if (mub > 1) mub = 1;
|
||||
if (mua < 0)
|
||||
mua = 0;
|
||||
if (mub < 0)
|
||||
mub = 0;
|
||||
if (mua > 1)
|
||||
mua = 1;
|
||||
if (mub > 1)
|
||||
mub = 1;
|
||||
c1 = p1.lerp(p2, mua);
|
||||
c2 = q1.lerp(q2, mub);
|
||||
}
|
||||
@@ -497,7 +501,8 @@ public:
|
||||
|
||||
bool orientation = an.cross(bn) > 0;
|
||||
|
||||
if ((bn.cross(cn) > 0) != orientation) return false;
|
||||
if ((bn.cross(cn) > 0) != orientation)
|
||||
return false;
|
||||
|
||||
return (cn.cross(an) > 0) == orientation;
|
||||
}
|
||||
@@ -683,7 +688,8 @@ public:
|
||||
|
||||
// If the term we intend to square root is less than 0 then the answer won't be real,
|
||||
// so it definitely won't be t in the range 0 to 1.
|
||||
if (sqrtterm < 0) return -1;
|
||||
if (sqrtterm < 0)
|
||||
return -1;
|
||||
|
||||
// If we can assume that the line segment starts outside the circle (e.g. for continuous time collision detection)
|
||||
// then the following can be skipped and we can just return the equivalent of res1.
|
||||
@@ -691,8 +697,10 @@ public:
|
||||
real_t res1 = (-b - sqrtterm) / (2 * a);
|
||||
real_t res2 = (-b + sqrtterm) / (2 * a);
|
||||
|
||||
if (res1 >= 0 && res1 <= 1) return res1;
|
||||
if (res2 >= 0 && res2 <= 1) return res2;
|
||||
if (res1 >= 0 && res1 <= 1)
|
||||
return res1;
|
||||
if (res2 >= 0 && res2 <= 1)
|
||||
return res2;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -233,12 +233,14 @@ public:
|
||||
static _ALWAYS_INLINE_ float range_lerp(float p_value, float p_istart, float p_istop, float p_ostart, float p_ostop) { return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value)); }
|
||||
|
||||
static _ALWAYS_INLINE_ double smoothstep(double p_from, double p_to, double p_weight) {
|
||||
if (is_equal_approx(p_from, p_to)) return p_from;
|
||||
if (is_equal_approx(p_from, p_to))
|
||||
return p_from;
|
||||
double x = CLAMP((p_weight - p_from) / (p_to - p_from), 0.0, 1.0);
|
||||
return x * x * (3.0 - 2.0 * x);
|
||||
}
|
||||
static _ALWAYS_INLINE_ float smoothstep(float p_from, float p_to, float p_weight) {
|
||||
if (is_equal_approx(p_from, p_to)) return p_from;
|
||||
if (is_equal_approx(p_from, p_to))
|
||||
return p_from;
|
||||
float x = CLAMP((p_weight - p_from) / (p_to - p_from), 0.0f, 1.0f);
|
||||
return x * x * (3.0f - 2.0f * x);
|
||||
}
|
||||
|
||||
@@ -206,7 +206,8 @@ Quat Quat::slerpni(const Quat &q, const real_t &t) const {
|
||||
|
||||
real_t dot = from.dot(q);
|
||||
|
||||
if (Math::absf(dot) > 0.9999) return from;
|
||||
if (Math::absf(dot) > 0.9999)
|
||||
return from;
|
||||
|
||||
real_t theta = Math::acos(dot),
|
||||
sinT = 1.0 / Math::sin(theta),
|
||||
|
||||
@@ -558,14 +558,16 @@ bool TriangleMesh::intersect_convex_shape(const Plane *p_planes, int p_plane_cou
|
||||
if (p.intersects_segment(point, next_point, &res)) {
|
||||
bool inisde = true;
|
||||
for (int k = 0; k < p_plane_count; k++) {
|
||||
if (k == i) continue;
|
||||
if (k == i)
|
||||
continue;
|
||||
const Plane &pp = p_planes[k];
|
||||
if (pp.is_point_over(res)) {
|
||||
inisde = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (inisde) return true;
|
||||
if (inisde)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (p.is_point_over(point)) {
|
||||
@@ -573,7 +575,8 @@ bool TriangleMesh::intersect_convex_shape(const Plane *p_planes, int p_plane_cou
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (over) return true;
|
||||
if (over)
|
||||
return true;
|
||||
}
|
||||
|
||||
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
|
||||
@@ -652,7 +655,8 @@ bool TriangleMesh::inside_convex_shape(const Plane *p_planes, int p_plane_count,
|
||||
case TEST_AABB_BIT: {
|
||||
|
||||
bool intersects = scale.xform(b.aabb).intersects_convex_shape(p_planes, p_plane_count, p_points, p_point_count);
|
||||
if (!intersects) return false;
|
||||
if (!intersects)
|
||||
return false;
|
||||
|
||||
bool inside = scale.xform(b.aabb).inside_convex_shape(p_planes, p_plane_count);
|
||||
if (inside) {
|
||||
@@ -667,7 +671,8 @@ bool TriangleMesh::inside_convex_shape(const Plane *p_planes, int p_plane_count,
|
||||
Vector3 point = scale.xform(vertexptr[s.indices[j]]);
|
||||
for (int i = 0; i < p_plane_count; i++) {
|
||||
const Plane &p = p_planes[i];
|
||||
if (p.is_point_over(point)) return false;
|
||||
if (p.is_point_over(point))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,13 +103,16 @@ bool Triangulate::snip(const Vector<Vector2> &p_contour, int u, int v, int w, in
|
||||
// To avoid that we allow zero-area triangles if all else failed.
|
||||
float threshold = relaxed ? -CMP_EPSILON : CMP_EPSILON;
|
||||
|
||||
if (threshold > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax)))) return false;
|
||||
if (threshold > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax))))
|
||||
return false;
|
||||
|
||||
for (p = 0; p < n; p++) {
|
||||
if ((p == u) || (p == v) || (p == w)) continue;
|
||||
if ((p == u) || (p == v) || (p == w))
|
||||
continue;
|
||||
Px = contour[V[p]].x;
|
||||
Py = contour[V[p]].y;
|
||||
if (is_inside_triangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py, relaxed)) return false;
|
||||
if (is_inside_triangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py, relaxed))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -119,7 +122,8 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour, Vector<int> &resul
|
||||
/* allocate and initialize list of Vertices in polygon */
|
||||
|
||||
int n = contour.size();
|
||||
if (n < 3) return false;
|
||||
if (n < 3)
|
||||
return false;
|
||||
|
||||
Vector<int> V;
|
||||
V.resize(n);
|
||||
@@ -161,11 +165,14 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour, Vector<int> &resul
|
||||
|
||||
/* three consecutive vertices in current polygon, <u,v,w> */
|
||||
int u = v;
|
||||
if (nv <= u) u = 0; /* previous */
|
||||
if (nv <= u)
|
||||
u = 0; /* previous */
|
||||
v = u + 1;
|
||||
if (nv <= v) v = 0; /* new v */
|
||||
if (nv <= v)
|
||||
v = 0; /* new v */
|
||||
int w = v + 1;
|
||||
if (nv <= w) w = 0; /* next */
|
||||
if (nv <= w)
|
||||
w = 0; /* next */
|
||||
|
||||
if (snip(contour, u, v, w, nv, V, relaxed)) {
|
||||
int a, b, c, s, t;
|
||||
|
||||
Reference in New Issue
Block a user