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.
This commit is contained in:
Alexander Gavrilov 2018-11-04 12:26:49 +03:00
parent a70589e439
commit 721a484ccb
1 changed files with 6 additions and 6 deletions

View File

@ -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);