--- ray/src/util/findglare.c 1991/04/02 16:47:03 1.14 +++ ray/src/util/findglare.c 1991/04/12 10:28:40 1.17 @@ -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])) @@ -50,6 +48,7 @@ main(argc, argv) int argc; char *argv[]; { + int combine = 1; int gotview = 0; int rval, i; char *err; @@ -103,6 +102,9 @@ char *argv[]; case 'p': picture = argv[++i]; break; + case 'c': + combine = !combine; + break; case 'd': case 'l': rtargv[rtargc++] = argv[i]; @@ -181,6 +183,8 @@ char *argv[]; if (threshold <= FTINY) comp_thresh(); /* compute glare threshold */ analyze(); /* analyze view */ + if (combine) + absorb_specks(); /* eliminate tiny sources */ cleanup(); /* tidy up */ /* print header */ printargs(argc, argv, stdout); @@ -277,7 +281,7 @@ init() /* initialize global variables */ cleanup() /* close files, wait for children */ { if (verbose) - fprintf(stderr, "%s: cleaning up...\n", progname); + fprintf(stderr, "%s: cleaning up... \n", progname); if (picture != NULL) close_pict(); if (octree != NULL) @@ -288,11 +292,11 @@ cleanup() /* close files, wait for children */ } -compdir(vd, x, y) /* compute direction for x,y */ +compdir(vd, x, y, se) /* compute direction for x,y */ FVECT vd; int x, y; +SPANERR *se; { - long t; FVECT org; /* dummy variable */ if (x <= -hlim) /* left region */ @@ -304,14 +308,25 @@ int x, y; (double)(x-hlim)/(2*sampdens)+.5, (double)y/(2*sampdens)+.5)); /* central region */ - /* avoid over-counting of poles */ - t = random() % vsize; - if (t*t >= (long)vsize*vsize - (long)y*y) - return(-1); + if (se != NULL) { /* avoid over-counting of poles */ + se->err += se->prob; + if (se->err <= 0.5) + return(-1); + se->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)); return(0); +} + + +setspanerr(se, y) /* initialize span error at y */ +register SPANERR *se; +int y; +{ + se->err = 0.0; + se->prob = sqrt(1.0 - (double)((long)y*y)/((long)vsize*vsize)); }