diff options
author | Mike Erwin <significant.bit@gmail.com> | 2016-07-23 03:59:31 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2016-07-23 04:00:12 +0300 |
commit | bd11d917c19aab91df9c2c7c721233fa73a1d1d7 (patch) | |
tree | c9d7d313854ad9575b8d23897919871e30cfab3f /source/blender | |
parent | 164575af29f94d8db78265df1520a3f7bfd3c72d (diff) |
fix atan2f input conditional
Suspicious conditional found by PVS-Studio T48917
Original code (from Blender’s initial open-source commit!) looks like
it’s testing inputs to atan2f, to avoid undefined function values.
Passing xn=0 does *not* always evaluate to 0 though… I’m not sure if
this is a coding error or was done for a desired visual result.
Also changed xn==0 to xn>=0 to avoid function call in more cases.
Good description and visualization of atan2f function:
http://en.cppreference.com/w/c/numeric/math/atan2
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/render/intern/source/renderdatabase.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index d3d26011a57..76e6ca8d467 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -1006,7 +1006,7 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, xn= har->xs - 0.5f*re->winx*(hoco1[0]/hoco1[3]); yn= har->ys - 0.5f*re->winy*(hoco1[1]/hoco1[3]); - if (xn==0.0f || (xn==0.0f && yn==0.0f)) zn= 0.0f; + if (yn == 0.0f && xn >= 0.0f) zn = 0.0f; else zn = atan2f(yn, xn); har->sin = sinf(zn); @@ -1136,7 +1136,7 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater xn= har->xs - 0.5f*re->winx*(hoco1[0]/hoco1[3]); yn= har->ys - 0.5f*re->winy*(hoco1[1]/hoco1[3]); - if (xn==0.0f || (xn==0.0f && yn==0.0f)) zn= 0.0; + if (yn == 0.0f && xn >= 0.0f) zn = 0.0f; else zn = atan2f(yn, xn); har->sin = sinf(zn); |