--- ray/src/util/rsensor.c 2011/05/19 16:09:38 2.10 +++ ray/src/util/rsensor.c 2013/10/16 04:35:50 2.13 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rsensor.c,v 2.10 2011/05/19 16:09:38 greg Exp $"; +static const char RCSid[] = "$Id: rsensor.c,v 2.13 2013/10/16 04:35:50 greg Exp $"; #endif /* @@ -398,9 +398,10 @@ init_ptable( tvals[i] = 1. - ( (1.-frac)*cos(thdiv[t]) + frac*cos(thdiv[t+1]) ); /* offset b/c sensor values are centered */ - if (!t || (t < sntp[0]-1) & (frac >= 0.5)) - frac -= 0.5; - else { + if ((t < sntp[0]-1) & (frac >= 0.5)) { + if ((frac -= 0.5) < 0) + frac = 0; + } else { frac += 0.5; --t; } @@ -470,16 +471,18 @@ sens_val( int t, p; dv[2] = DOT(dvec, ourview.vdir); - theta = (float)((1./DEGREE) * acos(dv[2])); + theta = acos(dv[2]); if (theta >= maxtheta) return(.0f); dv[0] = DOT(dvec, ourview.hvec); dv[1] = DOT(dvec, ourview.vvec); - phi = (float)((1./DEGREE) * atan2(-dv[0], dv[1])); - while (phi < .0f) phi += 360.f; + phi = atan2(-dv[0], dv[1]); + while (phi < .0f) phi += (float)(2.*PI); t = (int)(theta/maxtheta * sntp[0]); - p = (int)(phi*(1./360.) * sntp[1]); + p = (int)(phi*(1./(2.*PI)) * sntp[1]); /* hack for non-uniform sensor grid */ + theta *= (float)(1./DEGREE); + phi *= (float)(1./DEGREE); while (t+1 < sntp[0] && theta >= s_theta(t+1)) ++t; while (t-1 >= 0 && theta <= s_theta(t-1)) @@ -542,7 +545,7 @@ comp_sensor( continue; } rr.rmax = .0; - rayorigin(&rr, PRIMARY, NULL, NULL); + rayorigin(&rr, PRIMARY|SPECULAR, NULL, NULL); scalecolor(rr.rcoef, sf); if (ray_pqueue(&rr) == 1) addcolor(vsum, rr.rcol); @@ -558,7 +561,7 @@ comp_sensor( continue; } rr.rmax = .0; - rayorigin(&rr, PRIMARY, NULL, NULL); + rayorigin(&rr, PRIMARY|SPECULAR, NULL, NULL); scalecolor(rr.rcoef, sf); if (ray_pqueue(&rr) == 1) addcolor(vsum, rr.rcol);