ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/glaresrc.c
(Generate patch)

Comparing ray/src/util/glaresrc.c (file contents):
Revision 1.4 by greg, Tue Mar 19 09:10:58 1991 UTC vs.
Revision 1.6 by greg, Tue Mar 19 17:21:31 1991 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16   struct source   *curlist = NULL;        /* current source list */
17   struct source   *donelist = NULL;       /* finished sources */
18  
19 double  threshold;                      /* glare threshold */
19  
21
20   struct srcspan *
21   newspan(l, r, v, sb)            /* allocate a new source span */
22   int     l, r, v;
# Line 50 | Line 48 | analyze()                      /* analyze our scene */
48          if (spanbr == NULL)
49                  memerr("view span brightness buffer");
50          for (v = vsize; v >= -vsize; v--) {
51 +                close_sources(v);
52                  getviewspan(v, spanbr);
53                  left = hsize + 1;
54                  for (h = -hsize; h <= hsize; h++) {
# Line 73 | Line 72 | analyze()                      /* analyze our scene */
72                  }
73                  if (left < h)
74                          addsrcspan(newspan(left,h,v,spanbr));
76                close_sources(v);
75          }
76          close_allsrcs();
77          free((char *)spanbr);
# Line 167 | Line 165 | struct srcspan *nss;
165   {
166          struct source   *last, *cs, *this;
167          register struct srcspan *ss;
170        register int    res;
168  
169          cs = NULL;
170          for (this = curlist; this != NULL; this = this->next) {
# Line 181 | Line 178 | struct srcspan *nss;
178                                          mergesource(cs, this);
179                                          last->next = this->next;
180                                          free((char *)this);
181 +                                        this = last;
182                                  }
183                                  break;
184                          }
# Line 246 | Line 244 | int    v;
244  
245   close_allsrcs()                 /* done with everything */
246   {
247 <        register struct source  *this, *nsrc;
247 >        register struct source  *this, *next;
248  
249 <        for (this = curlist; this != NULL; this = nsrc) {
250 <                nsrc = this->next;
249 >        this = curlist;
250 >        while (this != NULL) {
251 >                next = this->next;
252                  donesource(this);
253 +                this = next;
254          }
255          curlist = NULL;
256   }
# Line 265 | Line 265 | register struct source *sp;
265          double  d;
266  
267          sp->dom = 0.0;
268 <        sp->dir[0] = sp->dir[1] = sp->dir[1] = 0.0;
268 >        sp->dir[0] = sp->dir[1] = sp->dir[2] = 0.0;
269          sp->brt = 0.0;
270          n = 0;
271          for (ss = sp->first; ss != NULL; ss = ss->next) {
272                  sp->brt += ss->brsum;
273                  n += ss->r - ss->l;
274 <                compdir(dright, ss->r, ss->v);
275 <                for (h = ss->r-1; h >= ss->l; h--) {
276 <                        compdir(dthis, h, ss->v);
277 <                        d = dist2(dthis, dright);
278 <                        fvsum(sp->dir, sp->dir, dthis, d);
279 <                        sp->dom += d;
280 <                        VCOPY(dright, dthis);
281 <                }
274 >                if (compdir(dright, ss->r, ss->v) < 0)
275 >                        compdir(dright, ss->r-2, ss->v);
276 >                for (h = ss->r-1; h >= ss->l; h--)
277 >                        if (compdir(dthis, h, ss->v) == 0) {
278 >                                d = dist2(dthis, dright);
279 >                                fvsum(sp->dir, sp->dir, dthis, d);
280 >                                sp->dom += d;
281 >                                VCOPY(dright, dthis);
282 >                        }
283                  free((char *)ss);
284          }
285          sp->first = NULL;
286          sp->brt /= (double)n;
287 <        sp->dir[0] /= sp->dom;
287 <        sp->dir[1] /= sp->dom;
288 <        sp->dir[2] /= sp->dom;
287 >        normalize(sp->dir);
288          sp->next = donelist;
289          donelist = sp;
290          if (verbose)
291                  fprintf(stderr,
292 <        "%s: found source at (%f,%f,%f), dw %f, br %f\n",
292 >        "%s: found source at (%.3f,%.3f,%.3f), dw %.5f, br %.1f (%d samps)\n",
293                          progname, sp->dir[0], sp->dir[1], sp->dir[2],
294 <                        sp->dom, sp->brt);
294 >                        sp->dom, sp->brt, n);
295   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines