bugfix [#22398] Black spots on reflecting surfaces when using Environment Light with HDR

acos() was being called with a value around  '-1.000001' because of float precission error.
This commit is contained in:
Campbell Barton 2010-05-23 21:38:27 +00:00
parent 735559f0da
commit 3aab8f245a

@ -2676,7 +2676,8 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f
switch(mtex->texco) {
case TEXCO_ANGMAP:
/* only works with texture being "real" */
fact= (1.0/M_PI)*acos(lo[2])/(sqrt(lo[0]*lo[0] + lo[1]*lo[1]));
/* use saacos(), fixes bug [#22398], float precission caused lo[2] to be slightly less then -1.0 */
fact= (1.0/M_PI)*saacos(lo[2])/(sqrt(lo[0]*lo[0] + lo[1]*lo[1]));
tempvec[0]= lo[0]*fact;
tempvec[1]= lo[1]*fact;
tempvec[2]= 0.0;