diff options
Diffstat (limited to 'source/blender/blenlib/intern/math_geom.c')
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 1cd1d1875fc..17a1dcbf34d 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; } |