You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
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:
@@ -45,15 +45,17 @@ void PhysicsDirectBodyState2D::integrate_forces() {
|
||||
|
||||
float damp = 1.0 - step * get_total_linear_damp();
|
||||
|
||||
if (damp < 0) // reached zero in the given time
|
||||
if (damp < 0) { // reached zero in the given time
|
||||
damp = 0;
|
||||
}
|
||||
|
||||
lv *= damp;
|
||||
|
||||
damp = 1.0 - step * get_total_angular_damp();
|
||||
|
||||
if (damp < 0) // reached zero in the given time
|
||||
if (damp < 0) { // reached zero in the given time
|
||||
damp = 0;
|
||||
}
|
||||
|
||||
av *= damp;
|
||||
|
||||
@@ -177,8 +179,9 @@ int PhysicsShapeQueryParameters2D::get_collision_mask() const {
|
||||
|
||||
void PhysicsShapeQueryParameters2D::set_exclude(const Vector<RID> &p_exclude) {
|
||||
exclude.clear();
|
||||
for (int i = 0; i < p_exclude.size(); i++)
|
||||
for (int i = 0; i < p_exclude.size(); i++) {
|
||||
exclude.insert(p_exclude[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Vector<RID> PhysicsShapeQueryParameters2D::get_exclude() const {
|
||||
@@ -254,13 +257,15 @@ PhysicsShapeQueryParameters2D::PhysicsShapeQueryParameters2D() {
|
||||
Dictionary PhysicsDirectSpaceState2D::_intersect_ray(const Vector2 &p_from, const Vector2 &p_to, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) {
|
||||
RayResult inters;
|
||||
Set<RID> exclude;
|
||||
for (int i = 0; i < p_exclude.size(); i++)
|
||||
for (int i = 0; i < p_exclude.size(); i++) {
|
||||
exclude.insert(p_exclude[i]);
|
||||
}
|
||||
|
||||
bool res = intersect_ray(p_from, p_to, inters, exclude, p_layers, p_collide_with_bodies, p_collide_with_areas);
|
||||
|
||||
if (!res)
|
||||
if (!res) {
|
||||
return Dictionary();
|
||||
}
|
||||
|
||||
Dictionary d;
|
||||
d["position"] = inters.position;
|
||||
@@ -300,8 +305,9 @@ Array PhysicsDirectSpaceState2D::_cast_motion(const Ref<PhysicsShapeQueryParamet
|
||||
|
||||
float closest_safe, closest_unsafe;
|
||||
bool res = cast_motion(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, closest_safe, closest_unsafe, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas);
|
||||
if (!res)
|
||||
if (!res) {
|
||||
return Array();
|
||||
}
|
||||
Array ret;
|
||||
ret.resize(2);
|
||||
ret[0] = closest_safe;
|
||||
@@ -311,20 +317,23 @@ Array PhysicsDirectSpaceState2D::_cast_motion(const Ref<PhysicsShapeQueryParamet
|
||||
|
||||
Array PhysicsDirectSpaceState2D::_intersect_point_impl(const Vector2 &p_point, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_filter_by_canvas, ObjectID p_canvas_instance_id) {
|
||||
Set<RID> exclude;
|
||||
for (int i = 0; i < p_exclude.size(); i++)
|
||||
for (int i = 0; i < p_exclude.size(); i++) {
|
||||
exclude.insert(p_exclude[i]);
|
||||
}
|
||||
|
||||
Vector<ShapeResult> ret;
|
||||
ret.resize(p_max_results);
|
||||
|
||||
int rc;
|
||||
if (p_filter_by_canvas)
|
||||
if (p_filter_by_canvas) {
|
||||
rc = intersect_point(p_point, ret.ptrw(), ret.size(), exclude, p_layers, p_collide_with_bodies, p_collide_with_areas);
|
||||
else
|
||||
} else {
|
||||
rc = intersect_point_on_canvas(p_point, p_canvas_instance_id, ret.ptrw(), ret.size(), exclude, p_layers, p_collide_with_bodies, p_collide_with_areas);
|
||||
}
|
||||
|
||||
if (rc == 0)
|
||||
if (rc == 0) {
|
||||
return Array();
|
||||
}
|
||||
|
||||
Array r;
|
||||
r.resize(rc);
|
||||
@@ -355,12 +364,14 @@ Array PhysicsDirectSpaceState2D::_collide_shape(const Ref<PhysicsShapeQueryParam
|
||||
ret.resize(p_max_results * 2);
|
||||
int rc = 0;
|
||||
bool res = collide_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, ret.ptrw(), p_max_results, rc, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas);
|
||||
if (!res)
|
||||
if (!res) {
|
||||
return Array();
|
||||
}
|
||||
Array r;
|
||||
r.resize(rc * 2);
|
||||
for (int i = 0; i < rc * 2; i++)
|
||||
for (int i = 0; i < rc * 2; i++) {
|
||||
r[i] = ret[i];
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -371,8 +382,9 @@ Dictionary PhysicsDirectSpaceState2D::_get_rest_info(const Ref<PhysicsShapeQuery
|
||||
|
||||
bool res = rest_info(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, &sri, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas);
|
||||
Dictionary r;
|
||||
if (!res)
|
||||
if (!res) {
|
||||
return r;
|
||||
}
|
||||
|
||||
r["point"] = sri.point;
|
||||
r["normal"] = sri.normal;
|
||||
@@ -499,8 +511,9 @@ PhysicsTestMotionResult2D::PhysicsTestMotionResult2D() {
|
||||
|
||||
bool PhysicsServer2D::_body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) {
|
||||
MotionResult *r = nullptr;
|
||||
if (p_result.is_valid())
|
||||
if (p_result.is_valid()) {
|
||||
r = p_result->get_result_ptr();
|
||||
}
|
||||
return body_test_motion(p_body, p_from, p_motion, p_infinite_inertia, p_margin, r);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user