Style: Apply clang-tidy's readability-braces-around-statements

This commit is contained in:
Rémi Verschelde 2021-04-05 14:09:59 +02:00
parent 9bbe51dc27
commit d83761ba80
No known key found for this signature in database
GPG key ID: C3336907360768E1
32 changed files with 308 additions and 165 deletions

View file

@ -157,8 +157,9 @@ RES ResourceFormatLoaderCrypto::load(const String &p_path, const String &p_origi
return key;
} else if (el == "pub") {
CryptoKey *key = CryptoKey::create();
if (key)
if (key) {
key->load(p_path, true);
}
return key;
}
return nullptr;

View file

@ -113,8 +113,9 @@ DynamicBVH::Node *DynamicBVH::_remove_leaf(Node *leaf) {
prev->volume = prev->childs[0]->volume.merge(prev->childs[1]->volume);
if (pb.is_not_equal_to(prev->volume)) {
prev = prev->parent;
} else
} else {
break;
}
}
return (prev ? prev : bvh_root);
} else {
@ -262,10 +263,11 @@ DynamicBVH::Node *DynamicBVH::_node_sort(Node *n, Node *&r) {
Node *s = p->childs[j];
Node *q = p->parent;
ERR_FAIL_COND_V(n != p->childs[i], nullptr);
if (q)
if (q) {
q->childs[p->get_index_in_parent()] = n;
else
} else {
r = n;
}
s->parent = n;
p->parent = n;
n->parent = q;
@ -307,8 +309,9 @@ void DynamicBVH::optimize_top_down(int bu_threshold) {
}
void DynamicBVH::optimize_incremental(int passes) {
if (passes < 0)
if (passes < 0) {
passes = total_leaves;
}
if (bvh_root && (passes > 0)) {
do {
Node *node = bvh_root;
@ -345,8 +348,9 @@ void DynamicBVH::_update(Node *leaf, int lookahead) {
for (int i = 0; (i < lookahead) && root->parent; ++i) {
root = root->parent;
}
} else
} else {
root = bvh_root;
}
}
_insert_leaf(root, leaf);
}
@ -370,8 +374,9 @@ bool DynamicBVH::update(const ID &p_id, const AABB &p_box) {
for (int i = 0; (i < lkhd) && base->parent; ++i) {
base = base->parent;
}
} else
} else {
base = bvh_root;
}
}
leaf->volume = volume;
_insert_leaf(base, leaf);

View file

@ -87,14 +87,16 @@ private:
_FORCE_INLINE_ Volume merge(const Volume &b) const {
Volume r;
for (int i = 0; i < 3; ++i) {
if (min[i] < b.min[i])
if (min[i] < b.min[i]) {
r.min[i] = min[i];
else
} else {
r.min[i] = b.min[i];
if (max[i] > b.max[i])
}
if (max[i] > b.max[i]) {
r.max[i] = max[i];
else
} else {
r.max[i] = b.max[i];
}
}
return r;
}
@ -202,10 +204,11 @@ private:
//
int count_leaves() const {
if (is_internal())
if (is_internal()) {
return childs[0]->count_leaves() + childs[1]->count_leaves();
else
} else {
return (1);
}
}
bool is_left_of_axis(const Vector3 &org, const Vector3 &axis) const {
@ -254,24 +257,30 @@ private:
tymin = (bounds[raySign[1]].y - rayFrom.y) * rayInvDirection.y;
tymax = (bounds[1 - raySign[1]].y - rayFrom.y) * rayInvDirection.y;
if ((tmin > tymax) || (tymin > tmax))
if ((tmin > tymax) || (tymin > tmax)) {
return false;
}
if (tymin > tmin)
if (tymin > tmin) {
tmin = tymin;
}
if (tymax < tmax)
if (tymax < tmax) {
tmax = tymax;
}
tzmin = (bounds[raySign[2]].z - rayFrom.z) * rayInvDirection.z;
tzmax = (bounds[1 - raySign[2]].z - rayFrom.z) * rayInvDirection.z;
if ((tmin > tzmax) || (tzmin > tmax))
if ((tmin > tzmax) || (tzmin > tmax)) {
return false;
if (tzmin > tmin)
}
if (tzmin > tmin) {
tmin = tzmin;
if (tzmax < tmax)
}
if (tzmax < tmax) {
tmax = tzmax;
}
return ((tmin < lambda_max) && (tmax > lambda_min));
}

View file

@ -891,8 +891,9 @@ struct VariantIndexedSetGet_Array {
static void ptr_get(const void *base, int64_t index, void *member) {
/* avoid ptrconvert for performance*/
const Array &v = *reinterpret_cast<const Array *>(base);
if (index < 0)
if (index < 0) {
index += v.size();
}
OOB_TEST(index, v.size());
PtrToArg<Variant>::encode(v[index], member);
}
@ -925,8 +926,9 @@ struct VariantIndexedSetGet_Array {
static void ptr_set(void *base, int64_t index, const void *member) {
/* avoid ptrconvert for performance*/
Array &v = *reinterpret_cast<Array *>(base);
if (index < 0)
if (index < 0) {
index += v.size();
}
OOB_TEST(index, v.size());
v.set(index, PtrToArg<Variant>::convert(member));
}