[Bf-blender-cvs] [bd11d91] master: fix atan2f input conditional
Mike Erwin
noreply at git.blender.org
Sat Jul 23 03:01:55 CEST 2016
Commit: bd11d917c19aab91df9c2c7c721233fa73a1d1d7
Author: Mike Erwin
Date: Fri Jul 22 20:59:31 2016 -0400
Branches: master
https://developer.blender.org/rBbd11d917c19aab91df9c2c7c721233fa73a1d1d7
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
===================================================================
M source/blender/render/intern/source/renderdatabase.c
===================================================================
diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c
index d3d2601..76e6ca8 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);
More information about the Bf-blender-cvs
mailing list