[Bf-blender-cvs] [106ea0b] master: Cleanup: sync map_to_sphere, UNLIKELY xy zero case
Campbell Barton
noreply at git.blender.org
Tue Sep 16 04:45:47 CEST 2014
Commit: 106ea0b20b216ebdc25e18742810aa1cf94ffa27
Author: Campbell Barton
Date: Tue Sep 16 12:41:16 2014 +1000
Branches: master
https://developer.blender.org/rB106ea0b20b216ebdc25e18742810aa1cf94ffa27
Cleanup: sync map_to_sphere, UNLIKELY xy zero case
===================================================================
M intern/cycles/util/util_math.h
M source/blender/blenlib/intern/math_geom.c
===================================================================
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index 1e8d8f3..c332e17 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;
}
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 1cd1d18..17a1dcb 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -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;
}
More information about the Bf-blender-cvs
mailing list