--- ray/src/util/glaresrc.c 1991/03/20 12:18:14 1.7 +++ ray/src/util/glaresrc.c 1991/04/10 15:59:10 1.11 @@ -49,6 +49,11 @@ analyze() /* analyze our scene */ memerr("view span brightness buffer"); for (v = vsize; v >= -vsize; v--) { close_sources(v); +#ifndef DEBUG + if (verbose) + fprintf(stderr, "%s: analyzing... %3ld%%\r", + progname, 100L*(vsize-v)/(2*vsize)); +#endif getviewspan(v, spanbr); left = hsize + 1; for (h = -hsize; h <= hsize; h++) { @@ -75,7 +80,6 @@ analyze() /* analyze our scene */ } free((char *)spanbr); close_allsrcs(); - absorb_specks(); } @@ -87,29 +91,29 @@ double br; register int i; if (h <= -hlim) { /* left region */ - d = (double)(h+hlim)/sampdens; - if (d <= -1.0+FTINY) + d = (double)(-h-hlim)/sampdens; + if (d >= 1.0-FTINY) return; tanb = d/sqrt(1.0-d*d); for (i = 0; i < nglardirs; i++) { d = indirect[i].lcos - tanb*indirect[i].lsin; if (d > 0.0) { indirect[i].sum += d * br; - indirect[i].n++; + indirect[i].n += d; } } return; } if (h >= hlim) { /* right region */ - d = (double)(h-hlim)/sampdens; - if (d >= 1.0-FTINY) + d = (double)(-h+hlim)/sampdens; + if (d <= -1.0+FTINY) return; tanb = d/sqrt(1.0-d*d); for (i = 0; i < nglardirs; i++) { d = indirect[i].rcos - tanb*indirect[i].rsin; if (d > 0.0) { indirect[i].sum += d * br; - indirect[i].n++; + indirect[i].n += d; } } return; @@ -119,7 +123,7 @@ double br; d = cos(h_theta(h) - indirect[i].theta); if (d > 0.0) { indirect[i].sum += d * br; - indirect[i].n++; + indirect[i].n += d; } } } @@ -153,7 +157,9 @@ comp_thresh() /* compute glare threshold */ exit(1); } if (verbose) { +#ifdef DEBUG pict_stats(); +#endif fprintf(stderr, "%s: threshold set to %f cd/m2 from %d samples\n", progname, threshold, nsamps); @@ -333,10 +339,10 @@ absorb_specks() /* eliminate too-small sources */ fprintf(stderr, "%s: absorbing small sources...\n", progname); head.next = donelist; last = &head; - for (this = donelist; this != NULL; this = this->next) + for (this = head.next; this != NULL; this = this->next) if (TOOSMALL(this)) { last->next = this->next; - buddy = findbuddy(this, donelist); + buddy = findbuddy(this, head.next); if (buddy != NULL) mergesource(buddy, this); else @@ -352,15 +358,16 @@ absorb(s) /* absorb a source into indirect */ register struct source *s; { FVECT dir; - register int i, n; + double d; + register int i; for (i = 0; i < nglardirs; i++) { spinvector(dir, ourview.vdir, ourview.vup, indirect[i].theta); - n = DOT(dir,s->dir)*s->dom*(sampdens*sampdens) + 0.5; - if (n == 0) + d = DOT(dir,s->dir)*s->dom*(sampdens*sampdens); + if (d <= 0.0) continue; - indirect[i].sum += n * s->brt; - indirect[i].n += n; + indirect[i].sum += d * s->brt; + indirect[i].n += d; } for ( ; s->first != NULL; s->first = s->first->next) free((char *)s->first);