--- ray/src/util/glaresrc.c 1991/03/21 14:53:56 1.9 +++ ray/src/util/glaresrc.c 1991/04/10 15:59:10 1.11 @@ -80,7 +80,6 @@ analyze() /* analyze our scene */ } free((char *)spanbr); close_allsrcs(); - absorb_specks(); } @@ -100,7 +99,7 @@ double br; 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; @@ -114,7 +113,7 @@ double br; 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; @@ -124,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; } } } @@ -340,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 @@ -359,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);