From 106ea0b20b216ebdc25e18742810aa1cf94ffa27 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 16 Sep 2014 12:41:16 +1000 Subject: Cleanup: sync map_to_sphere, UNLIKELY xy zero case --- intern/cycles/util/util_math.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'intern') diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index 1e8d8f37d1e..c332e1709db 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -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; } -- cgit v1.2.3