--- ray/src/util/findglare.c 1991/04/02 16:47:03 1.14 +++ ray/src/util/findglare.c 1991/04/05 14:26:47 1.15 @@ -12,8 +12,6 @@ static char SCCSid[] = "$SunId$ LBL"; #include "glare.h" -#include "random.h" - #define FEQ(a,b) ((a)-(b)<=FTINY&&(a)-(b)<=FTINY) #define VEQ(v1,v2) (FEQ((v1)[0],(v2)[0])&&FEQ((v1)[1],(v2)[1]) \ &&FEQ((v1)[2],(v2)[2])) @@ -292,6 +290,8 @@ compdir(vd, x, y) /* compute direction for x,y */ FVECT vd; int x, y; { + static int cury = 10000; + static double err, cmpval; long t; FVECT org; /* dummy variable */ @@ -305,9 +305,15 @@ int x, y; (double)y/(2*sampdens)+.5)); /* central region */ /* avoid over-counting of poles */ - t = random() % vsize; - if (t*t >= (long)vsize*vsize - (long)y*y) + if (cury != y) { + err = 0.0; + cmpval = sqrt(1.0 - (double)((long)y*y)/((long)vsize*vsize)); + cury = y; + } + err += cmpval; + if (err <= 0.5) return(-1); + err -= 1.0; if (viewray(org, vd, &ourview, .5, (double)y/(2*sampdens)+.5) < 0) return(-1); spinvector(vd, vd, ourview.vup, h_theta(x));