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:
authorAlexander Gavrilov <angavrilov@gmail.com>2018-11-04 12:26:49 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2018-11-05 17:16:06 +0300
commit721a484ccb3c66f49665988d624e5992e457cdde (patch)
tree2244941211869528e69b9d994b78497209c142e2 /source/blender/blenlib/intern/BLI_kdopbvh.c
parenta70589e439b3fb00fb5c54971df823931a8d00eb (diff)
BLI_kdopbvh: reduce branching in calc_nearest_point_squared.
This lets the compiler use min/max instructions for 4.5% FPS improvement in Shrinkwrap to Nearest Surface Point.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_kdopbvh.c')
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index 45198af0515..ebe73ed1044 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -1266,12 +1266,12 @@ static float calc_nearest_point_squared(const float proj[3], BVHNode *node, floa
/* nearest on AABB hull */
for (i = 0; i != 3; i++, bv += 2) {
- if (bv[0] > proj[i])
- nearest[i] = bv[0];
- else if (bv[1] < proj[i])
- nearest[i] = bv[1];
- else
- nearest[i] = proj[i];
+ float val = proj[i];
+ if (bv[0] > val)
+ val = bv[0];
+ if (bv[1] < val)
+ val = bv[1];
+ nearest[i] = val;
}
return len_squared_v3v3(proj, nearest);