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.5 by greg, Tue Mar 19 17:06:25 1991 UTC

# Line 50 | Line 50 | analyze()                      /* analyze our scene */
50          if (spanbr == NULL)
51                  memerr("view span brightness buffer");
52          for (v = vsize; v >= -vsize; v--) {
53 +                close_sources(v);
54                  getviewspan(v, spanbr);
55                  left = hsize + 1;
56                  for (h = -hsize; h <= hsize; h++) {
# Line 73 | Line 74 | analyze()                      /* analyze our scene */
74                  }
75                  if (left < h)
76                          addsrcspan(newspan(left,h,v,spanbr));
76                close_sources(v);
77          }
78          close_allsrcs();
79          free((char *)spanbr);
# Line 167 | Line 167 | struct srcspan *nss;
167   {
168          struct source   *last, *cs, *this;
169          register struct srcspan *ss;
170        register int    res;
170  
171          cs = NULL;
172          for (this = curlist; this != NULL; this = this->next) {
# Line 181 | Line 180 | struct srcspan *nss;
180                                          mergesource(cs, this);
181                                          last->next = this->next;
182                                          free((char *)this);
183 +                                        this = last;
184                                  }
185                                  break;
186                          }
# Line 246 | Line 246 | int    v;
246  
247   close_allsrcs()                 /* done with everything */
248   {
249 <        register struct source  *this, *nsrc;
249 >        register struct source  *this, *next;
250  
251 <        for (this = curlist; this != NULL; this = nsrc) {
252 <                nsrc = this->next;
251 >        this = curlist;
252 >        while (this != NULL) {
253 >                next = this->next;
254                  donesource(this);
255 +                this = next;
256          }
257          curlist = NULL;
258   }
# Line 265 | Line 267 | register struct source *sp;
267          double  d;
268  
269          sp->dom = 0.0;
270 <        sp->dir[0] = sp->dir[1] = sp->dir[1] = 0.0;
270 >        sp->dir[0] = sp->dir[1] = sp->dir[2] = 0.0;
271          sp->brt = 0.0;
272          n = 0;
273          for (ss = sp->first; ss != NULL; ss = ss->next) {
274                  sp->brt += ss->brsum;
275                  n += ss->r - ss->l;
276 <                compdir(dright, ss->r, ss->v);
277 <                for (h = ss->r-1; h >= ss->l; h--) {
278 <                        compdir(dthis, h, ss->v);
279 <                        d = dist2(dthis, dright);
280 <                        fvsum(sp->dir, sp->dir, dthis, d);
281 <                        sp->dom += d;
282 <                        VCOPY(dright, dthis);
283 <                }
276 >                if (compdir(dright, ss->r, ss->v) < 0)
277 >                        compdir(dright, ss->r-2, ss->v);
278 >                for (h = ss->r-1; h >= ss->l; h--)
279 >                        if (compdir(dthis, h, ss->v) == 0) {
280 >                                d = dist2(dthis, dright);
281 >                                fvsum(sp->dir, sp->dir, dthis, d);
282 >                                sp->dom += d;
283 >                                VCOPY(dright, dthis);
284 >                        }
285                  free((char *)ss);
286          }
287          sp->first = NULL;
288          sp->brt /= (double)n;
289 <        sp->dir[0] /= sp->dom;
287 <        sp->dir[1] /= sp->dom;
288 <        sp->dir[2] /= sp->dom;
289 >        normalize(sp->dir);
290          sp->next = donelist;
291          donelist = sp;
292          if (verbose)
293                  fprintf(stderr,
294 <        "%s: found source at (%f,%f,%f), dw %f, br %f\n",
294 >        "%s: found source at (%.3f,%.3f,%.3f), dw %.5f, br %.1f (%d samps)\n",
295                          progname, sp->dir[0], sp->dir[1], sp->dir[2],
296 <                        sp->dom, sp->brt);
296 >                        sp->dom, sp->brt, n);
297   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines