Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-08-07 12:23:02 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-08-07 12:23:02 +0300
commita29686eeb3af051a00fbb8a8b9be06bcd050ec8c (patch)
tree9da60e7257e3e2dafda3e9b565b77c9c6f37675b /source/blender/blenlib/intern/BLI_kdopbvh.c
parente0c51b466f3b23a1fc114690be2b008e19637ea6 (diff)
Cleanup: Blenlib, Clang-Tidy else-after-return fixes (incomplete)
This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/blenlib` module. Not all warnings are addressed in this commit. No functional changes.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_kdopbvh.c')
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c90
1 files changed, 34 insertions, 56 deletions
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index a3f93ccc753..f63a523ca60 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -284,28 +284,19 @@ static BVHNode *bvh_medianof3(BVHNode **a, int lo, int mid, int hi, int axis)
if ((a[hi])->bv[axis] < (a[mid])->bv[axis]) {
return a[mid];
}
- else {
- if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
- return a[hi];
- }
- else {
- return a[lo];
- }
+ if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
+ return a[hi];
}
+ return a[lo];
}
- else {
- if ((a[hi])->bv[axis] < (a[mid])->bv[axis]) {
- if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
- return a[lo];
- }
- else {
- return a[hi];
- }
- }
- else {
- return a[mid];
+
+ if ((a[hi])->bv[axis] < (a[mid])->bv[axis]) {
+ if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
+ return a[lo];
}
+ return a[hi];
}
+ return a[mid];
}
/**
@@ -422,18 +413,12 @@ static char get_largest_axis(const float *bv)
if (middle_point[0] > middle_point[2]) {
return 1; /* max x axis */
}
- else {
- return 5; /* max z axis */
- }
+ return 5; /* max z axis */
}
- else {
- if (middle_point[1] > middle_point[2]) {
- return 3; /* max y axis */
- }
- else {
- return 5; /* max z axis */
- }
+ if (middle_point[1] > middle_point[2]) {
+ return 3; /* max y axis */
}
+ return 5; /* max z axis */
}
/**
@@ -619,13 +604,11 @@ static int implicit_leafs_index(const BVHBuildHelper *data, const int depth, con
if (min_leaf_index <= data->remain_leafs) {
return min_leaf_index;
}
- else if (data->leafs_per_child[depth]) {
+ if (data->leafs_per_child[depth]) {
return data->totleafs -
(data->branches_on_level[depth - 1] - child_index) * data->leafs_per_child[depth];
}
- else {
- return data->remain_leafs;
- }
+ return data->remain_leafs;
}
/**
@@ -1668,10 +1651,8 @@ static bool dfs_find_duplicate_fast_dfs(BVHNearestData *data, BVHNode *node)
data->callback(data->userdata, node->index, data->co, &data->nearest);
return (data->nearest.dist_sq < dist_sq);
}
- else {
- data->nearest.index = node->index;
- return true;
- }
+ data->nearest.index = node->index;
+ return true;
}
}
else {
@@ -1805,9 +1786,7 @@ static float fast_ray_nearest_hit(const BVHRayCastData *data, const BVHNode *nod
(t1x > data->hit.dist || t1y > data->hit.dist || t1z > data->hit.dist)) {
return FLT_MAX;
}
- else {
- return max_fff(t1x, t1y, t1z);
- }
+ return max_fff(t1x, t1y, t1z);
}
static void dfs_raycast(BVHRayCastData *data, BVHNode *node)
@@ -2354,26 +2333,25 @@ static bool bvhtree_walk_dfs_recursive(BVHTree_WalkData *walk_data, const BVHNod
return walk_data->walk_leaf_cb(
(const BVHTreeAxisRange *)node->bv, node->index, walk_data->userdata);
}
- else {
- /* First pick the closest node to recurse into */
- if (walk_data->walk_order_cb(
- (const BVHTreeAxisRange *)node->bv, node->main_axis, walk_data->userdata)) {
- for (int i = 0; i != node->totnode; i++) {
- if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv,
- walk_data->userdata)) {
- if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) {
- return false;
- }
+
+ /* First pick the closest node to recurse into */
+ if (walk_data->walk_order_cb(
+ (const BVHTreeAxisRange *)node->bv, node->main_axis, walk_data->userdata)) {
+ for (int i = 0; i != node->totnode; i++) {
+ if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv,
+ walk_data->userdata)) {
+ if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) {
+ return false;
}
}
}
- else {
- for (int i = node->totnode - 1; i >= 0; i--) {
- if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv,
- walk_data->userdata)) {
- if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) {
- return false;
- }
+ }
+ else {
+ for (int i = node->totnode - 1; i >= 0; i--) {
+ if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv,
+ walk_data->userdata)) {
+ if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) {
+ return false;
}
}
}