Cleanup: sync map_to_sphere, UNLIKELY xy zero case
authorCampbell Barton <ideasman42@gmail.com>
Tue, 16 Sep 2014 02:41:16 +0000 (12:41 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 16 Sep 2014 02:41:16 +0000 (12:41 +1000)
intern/cycles/util/util_math.h
source/blender/blenlib/intern/math_geom.c

index 1e8d8f37d1e38e755bbc12077de322a9ea2ed67e..c332e1709dbb472858522b33cbdddbd994ef903a 100644 (file)
@@ -1419,10 +1419,12 @@ ccl_device bool map_to_sphere(float *r_u, float *r_v,
 {
        float len = sqrtf(x * x + y * y + z * z);
        if(len > 0.0f) {
-               if(x == 0.0f && y == 0.0f)
+               if(UNLIKELY(x == 0.0f && y == 0.0f)) {
                        *r_u = 0.0f;  /* othwise domain error */
-               else
+               }
+               else {
                        *r_u = (1.0f - atan2f(x, y) / M_PI_F) / 2.0f;
+               }
                *r_v = 1.0f - safe_acosf(z / len) / M_PI_F;
                return true;
        }
index 1cd1d1875fced22b113f1bd20da2ceda8d0f27cb..17a1dcbf34d15580f801a49f0dea9f778ee88a3b 100644 (file)
@@ -3206,8 +3206,12 @@ void map_to_sphere(float *r_u, float *r_v, const float x, const float y, const f
 
        len = sqrtf(x * x + y * y + z * z);
        if (len > 0.0f) {
-               if (x == 0.0f && y == 0.0f) *r_u = 0.0f;  /* othwise domain error */
-               else *r_u = (1.0f - atan2f(x, y) / (float)M_PI) / 2.0f;
+               if (UNLIKELY(x == 0.0f && y == 0.0f)) {
+                       *r_u = 0.0f;  /* othwise domain error */
+               }
+               else {
+                       *r_u = (1.0f - atan2f(x, y) / (float)M_PI) / 2.0f;
+               }
 
                *r_v = 1.0f - saacos(z / len) / (float)M_PI;
        }