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:
@@ -38,8 +38,9 @@
|
||||
|
||||
bool CollisionSolver3DSW::solve_static_plane(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
|
||||
const PlaneShape3DSW *plane = static_cast<const PlaneShape3DSW *>(p_shape_A);
|
||||
if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE)
|
||||
if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE) {
|
||||
return false;
|
||||
}
|
||||
Plane p = p_transform_A.xform(plane->get_plane());
|
||||
|
||||
static const int max_supports = 16;
|
||||
@@ -52,17 +53,19 @@ bool CollisionSolver3DSW::solve_static_plane(const Shape3DSW *p_shape_A, const T
|
||||
|
||||
for (int i = 0; i < support_count; i++) {
|
||||
supports[i] = p_transform_B.xform(supports[i]);
|
||||
if (p.distance_to(supports[i]) >= 0)
|
||||
if (p.distance_to(supports[i]) >= 0) {
|
||||
continue;
|
||||
}
|
||||
found = true;
|
||||
|
||||
Vector3 support_A = p.project(supports[i]);
|
||||
|
||||
if (p_result_callback) {
|
||||
if (p_swap_result)
|
||||
if (p_swap_result) {
|
||||
p_result_callback(supports[i], support_A, p_userdata);
|
||||
else
|
||||
} else {
|
||||
p_result_callback(support_A, supports[i], p_userdata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +85,9 @@ bool CollisionSolver3DSW::solve_ray(const Shape3DSW *p_shape_A, const Transform
|
||||
to = ai.xform(to);
|
||||
|
||||
Vector3 p, n;
|
||||
if (!p_shape_B->intersect_segment(from, to, p, n))
|
||||
if (!p_shape_B->intersect_segment(from, to, p, n)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 support_B = p_transform_B.xform(p);
|
||||
if (ray->get_slips_on_slope()) {
|
||||
@@ -92,10 +96,11 @@ bool CollisionSolver3DSW::solve_ray(const Shape3DSW *p_shape_A, const Transform
|
||||
}
|
||||
|
||||
if (p_result_callback) {
|
||||
if (p_swap_result)
|
||||
if (p_swap_result) {
|
||||
p_result_callback(support_B, support_A, p_userdata);
|
||||
else
|
||||
} else {
|
||||
p_result_callback(support_A, support_B, p_userdata);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -121,8 +126,9 @@ void CollisionSolver3DSW::concave_callback(void *p_userdata, Shape3DSW *p_convex
|
||||
cinfo.aabb_tests++;
|
||||
|
||||
bool collided = collision_solver(cinfo.shape_A, *cinfo.transform_A, p_convex, *cinfo.transform_B, cinfo.result_callback, cinfo.userdata, cinfo.swap_result, nullptr, cinfo.margin_A, cinfo.margin_B);
|
||||
if (!collided)
|
||||
if (!collided) {
|
||||
return;
|
||||
}
|
||||
|
||||
cinfo.collided = true;
|
||||
cinfo.collisions++;
|
||||
@@ -187,8 +193,9 @@ bool CollisionSolver3DSW::solve_static(const Shape3DSW *p_shape_A, const Transfo
|
||||
}
|
||||
|
||||
if (type_A == PhysicsServer3D::SHAPE_PLANE) {
|
||||
if (type_B == PhysicsServer3D::SHAPE_PLANE)
|
||||
if (type_B == PhysicsServer3D::SHAPE_PLANE) {
|
||||
return false;
|
||||
}
|
||||
if (type_B == PhysicsServer3D::SHAPE_RAY) {
|
||||
return false;
|
||||
}
|
||||
@@ -200,8 +207,9 @@ bool CollisionSolver3DSW::solve_static(const Shape3DSW *p_shape_A, const Transfo
|
||||
}
|
||||
|
||||
} else if (type_A == PhysicsServer3D::SHAPE_RAY) {
|
||||
if (type_B == PhysicsServer3D::SHAPE_RAY)
|
||||
if (type_B == PhysicsServer3D::SHAPE_RAY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (swap) {
|
||||
return solve_ray(p_shape_B, p_transform_B, p_shape_A, p_transform_A, p_result_callback, p_userdata, true);
|
||||
@@ -210,13 +218,15 @@ bool CollisionSolver3DSW::solve_static(const Shape3DSW *p_shape_A, const Transfo
|
||||
}
|
||||
|
||||
} else if (concave_B) {
|
||||
if (concave_A)
|
||||
if (concave_A) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!swap)
|
||||
if (!swap) {
|
||||
return solve_concave(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false, p_margin_A, p_margin_B);
|
||||
else
|
||||
} else {
|
||||
return solve_concave(p_shape_B, p_transform_B, p_shape_A, p_transform_A, p_result_callback, p_userdata, true, p_margin_A, p_margin_B);
|
||||
}
|
||||
|
||||
} else {
|
||||
return collision_solver(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false, r_sep_axis, p_margin_A, p_margin_B);
|
||||
@@ -226,14 +236,16 @@ bool CollisionSolver3DSW::solve_static(const Shape3DSW *p_shape_A, const Transfo
|
||||
void CollisionSolver3DSW::concave_distance_callback(void *p_userdata, Shape3DSW *p_convex) {
|
||||
_ConcaveCollisionInfo &cinfo = *(_ConcaveCollisionInfo *)(p_userdata);
|
||||
cinfo.aabb_tests++;
|
||||
if (cinfo.collided)
|
||||
if (cinfo.collided) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 close_A, close_B;
|
||||
cinfo.collided = !gjk_epa_calculate_distance(cinfo.shape_A, *cinfo.transform_A, p_convex, *cinfo.transform_B, close_A, close_B);
|
||||
|
||||
if (cinfo.collided)
|
||||
if (cinfo.collided) {
|
||||
return;
|
||||
}
|
||||
if (!cinfo.tested || close_A.distance_squared_to(close_B) < cinfo.close_A.distance_squared_to(cinfo.close_B)) {
|
||||
cinfo.close_A = close_A;
|
||||
cinfo.close_B = close_B;
|
||||
@@ -245,8 +257,9 @@ void CollisionSolver3DSW::concave_distance_callback(void *p_userdata, Shape3DSW
|
||||
|
||||
bool CollisionSolver3DSW::solve_distance_plane(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B) {
|
||||
const PlaneShape3DSW *plane = static_cast<const PlaneShape3DSW *>(p_shape_A);
|
||||
if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE)
|
||||
if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE) {
|
||||
return false;
|
||||
}
|
||||
Plane p = p_transform_A.xform(plane->get_plane());
|
||||
|
||||
static const int max_supports = 16;
|
||||
@@ -265,8 +278,9 @@ bool CollisionSolver3DSW::solve_distance_plane(const Shape3DSW *p_shape_A, const
|
||||
if (i == 0 || d < closest_d) {
|
||||
closest = supports[i];
|
||||
closest_d = d;
|
||||
if (d <= 0)
|
||||
if (d <= 0) {
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,8 +291,9 @@ bool CollisionSolver3DSW::solve_distance_plane(const Shape3DSW *p_shape_A, const
|
||||
}
|
||||
|
||||
bool CollisionSolver3DSW::solve_distance(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis) {
|
||||
if (p_shape_A->is_concave())
|
||||
if (p_shape_A->is_concave()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE) {
|
||||
Vector3 a, b;
|
||||
@@ -288,8 +303,9 @@ bool CollisionSolver3DSW::solve_distance(const Shape3DSW *p_shape_A, const Trans
|
||||
return !col;
|
||||
|
||||
} else if (p_shape_B->is_concave()) {
|
||||
if (p_shape_A->is_concave())
|
||||
if (p_shape_A->is_concave()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const ConcaveShape3DSW *concave_B = static_cast<const ConcaveShape3DSW *>(p_shape_B);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user