summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-04-05 14:34:31 +0200
committerGitHub <noreply@github.com>2021-04-05 14:34:31 +0200
commitb80b072c44cfc4f6ec1bfecc045374597eb296e0 (patch)
tree39544b604c8be6cf6daa56a2a7774426d394c2a3 /core
parent33b8f1448e3efd8ad71c65c3d42581fae82905a3 (diff)
parentd83761ba80b90e17aaefaa83c7ece0fa89511266 (diff)
Merge pull request #47642 from akien-mga/clang-tidy-fixes
Diffstat (limited to 'core')
-rw-r--r--core/crypto/crypto.cpp3
-rw-r--r--core/math/dynamic_bvh.cpp29
-rw-r--r--core/math/dynamic_bvh.h35
-rw-r--r--core/variant/variant_setget.cpp6
4 files changed, 45 insertions, 28 deletions
diff --git a/core/crypto/crypto.cpp b/core/crypto/crypto.cpp
index 6b3953f588..fe913549c9 100644
--- a/core/crypto/crypto.cpp
+++ b/core/crypto/crypto.cpp
@@ -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;
diff --git a/core/math/dynamic_bvh.cpp b/core/math/dynamic_bvh.cpp
index 4639a52278..200095d8cb 100644
--- a/core/math/dynamic_bvh.cpp
+++ b/core/math/dynamic_bvh.cpp
@@ -61,7 +61,7 @@ DynamicBVH::Node *DynamicBVH::_create_node_with_volume(Node *p_parent, const Vol
void DynamicBVH::_insert_leaf(Node *p_root, Node *p_leaf) {
if (!bvh_root) {
bvh_root = p_leaf;
- p_leaf->parent = 0;
+ p_leaf->parent = nullptr;
} else {
if (!p_root->is_leaf()) {
do {
@@ -71,7 +71,7 @@ void DynamicBVH::_insert_leaf(Node *p_root, Node *p_leaf) {
} while (!p_root->is_leaf());
}
Node *prev = p_root->parent;
- Node *node = _create_node_with_volume(prev, p_leaf->volume.merge(p_root->volume), 0);
+ Node *node = _create_node_with_volume(prev, p_leaf->volume.merge(p_root->volume), nullptr);
if (prev) {
prev->childs[p_root->get_index_in_parent()] = node;
node->childs[0] = p_root;
@@ -85,7 +85,7 @@ void DynamicBVH::_insert_leaf(Node *p_root, Node *p_leaf) {
break;
}
node = prev;
- } while (0 != (prev = node->parent));
+ } while (nullptr != (prev = node->parent));
} else {
node->childs[0] = p_root;
p_root->parent = node;
@@ -98,8 +98,8 @@ void DynamicBVH::_insert_leaf(Node *p_root, Node *p_leaf) {
DynamicBVH::Node *DynamicBVH::_remove_leaf(Node *leaf) {
if (leaf == bvh_root) {
- bvh_root = 0;
- return (0);
+ bvh_root = nullptr;
+ return (nullptr);
} else {
Node *parent = leaf->parent;
Node *prev = parent->parent;
@@ -113,13 +113,14 @@ 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 {
bvh_root = sibling;
- sibling->parent = 0;
+ sibling->parent = nullptr;
_delete_node(parent);
return (bvh_root);
}
@@ -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);
diff --git a/core/math/dynamic_bvh.h b/core/math/dynamic_bvh.h
index c71db2d24d..3fb22515a2 100644
--- a/core/math/dynamic_bvh.h
+++ b/core/math/dynamic_bvh.h
@@ -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,31 +257,37 @@ 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));
}
public:
// Methods
void clear();
- bool is_empty() const { return (0 == bvh_root); }
+ bool is_empty() const { return (nullptr == bvh_root); }
void optimize_bottom_up();
void optimize_top_down(int bu_threshold = 128);
void optimize_incremental(int passes);
diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp
index b86ae3ebb2..f319631ce5 100644
--- a/core/variant/variant_setget.cpp
+++ b/core/variant/variant_setget.cpp
@@ -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));
}