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.7 by greg, Wed Mar 20 12:18:14 1991 UTC vs.
Revision 1.12 by greg, Fri Apr 12 10:28:36 1991 UTC

# Line 49 | Line 49 | analyze()                      /* analyze our scene */
49                  memerr("view span brightness buffer");
50          for (v = vsize; v >= -vsize; v--) {
51                  close_sources(v);
52 + #ifndef DEBUG
53 +                if (verbose)
54 +                        fprintf(stderr, "%s: analyzing... %3ld%%\r",
55 +                                progname, 100L*(vsize-v)/(2*vsize));
56 + #endif
57                  getviewspan(v, spanbr);
58                  left = hsize + 1;
59                  for (h = -hsize; h <= hsize; h++) {
# Line 75 | Line 80 | analyze()                      /* analyze our scene */
80          }
81          free((char *)spanbr);
82          close_allsrcs();
78        absorb_specks();
83   }
84  
85  
# Line 87 | Line 91 | double br;
91          register int    i;
92  
93          if (h <= -hlim) {                       /* left region */
94 <                d = (double)(h+hlim)/sampdens;
95 <                if (d <= -1.0+FTINY)
94 >                d = (double)(-h-hlim)/sampdens;
95 >                if (d >= 1.0-FTINY)
96                          return;
97                  tanb = d/sqrt(1.0-d*d);
98                  for (i = 0; i < nglardirs; i++) {
99                          d = indirect[i].lcos - tanb*indirect[i].lsin;
100                          if (d > 0.0) {
101                                  indirect[i].sum += d * br;
102 <                                indirect[i].n++;
102 >                                indirect[i].n += d;
103                          }
104                  }
105                  return;
106          }
107          if (h >= hlim) {                        /* right region */
108 <                d = (double)(h-hlim)/sampdens;
109 <                if (d >= 1.0-FTINY)
108 >                d = (double)(-h+hlim)/sampdens;
109 >                if (d <= -1.0+FTINY)
110                          return;
111                  tanb = d/sqrt(1.0-d*d);
112                  for (i = 0; i < nglardirs; i++) {
113                          d = indirect[i].rcos - tanb*indirect[i].rsin;
114                          if (d > 0.0) {
115                                  indirect[i].sum += d * br;
116 <                                indirect[i].n++;
116 >                                indirect[i].n += d;
117                          }
118                  }
119                  return;
# Line 119 | Line 123 | double br;
123                  d = cos(h_theta(h) - indirect[i].theta);
124                  if (d > 0.0) {
125                          indirect[i].sum += d * br;
126 <                        indirect[i].n++;
126 >                        indirect[i].n += d;
127                  }
128          }
129   }
# Line 127 | Line 131 | double br;
131  
132   comp_thresh()                   /* compute glare threshold */
133   {
134 +        SPANERR sperr;
135          int     h, v;
136          int     nsamps;
137          double  brsum, br;
# Line 136 | Line 141 | comp_thresh()                  /* compute glare threshold */
141                                  progname);
142          brsum = 0.0;
143          nsamps = 0;
144 <        for (v = vsize; v >= -vsize; v -= TSAMPSTEP)
144 >        for (v = vsize; v >= -vsize; v -= TSAMPSTEP) {
145 >                setspanerr(&sperr, v);
146                  for (h = -hsize; h <= hsize; h += TSAMPSTEP) {
147 <                        if ((br = getviewpix(h, v)) < 0.0)
147 >                        if ((br = getviewpix(h, v, &sperr)) < 0.0)
148                                  continue;
149                          brsum += br;
150                          nsamps++;
151                  }
152 +        }
153          if (nsamps == 0) {
154                  fprintf(stderr, "%s: no viewable scene!\n", progname);
155                  exit(1);
# Line 153 | Line 160 | comp_thresh()                  /* compute glare threshold */
160                  exit(1);
161          }
162          if (verbose) {
163 + #ifdef DEBUG
164                  pict_stats();
165 + #endif
166                  fprintf(stderr,
167                          "%s: threshold set to %f cd/m2 from %d samples\n",
168                                  progname, threshold, nsamps);
# Line 281 | Line 290 | register struct source *sp;
290          for (ss = sp->first; ss != NULL; ss = ss->next) {
291                  sp->brt += ss->brsum;
292                  n += ss->r - ss->l;
293 <                if (compdir(dright, ss->r, ss->v) < 0)
294 <                        compdir(dright, ss->r-2, ss->v);
293 >                if (compdir(dright, ss->r, ss->v, NULL) < 0)
294 >                        compdir(dright, ss->r-2, ss->v, NULL);
295                  for (h = ss->r-1; h >= ss->l; h--)
296 <                        if (compdir(dthis, h, ss->v) == 0) {
296 >                        if (compdir(dthis, h, ss->v, NULL) == 0) {
297                                  d = dist2(dthis, dright);
298                                  fvsum(sp->dir, sp->dir, dthis, d);
299                                  sp->dom += d;
# Line 299 | Line 308 | register struct source *sp;
308          donelist = sp;
309          if (verbose)
310                  fprintf(stderr,
311 <        "%s: found source at (%.3f,%.3f,%.3f), dw %.5f, br %.1f (%d samps)\n",
311 >        "%s: source at [%.3f,%.3f,%.3f], dw %.5f, br %.1f (%d samps)\n",
312                          progname, sp->dir[0], sp->dir[1], sp->dir[2],
313                          sp->dom, sp->brt, n);
314   }
# Line 333 | Line 342 | absorb_specks()                        /* eliminate too-small sources */
342                  fprintf(stderr, "%s: absorbing small sources...\n", progname);
343          head.next = donelist;
344          last = &head;
345 <        for (this = donelist; this != NULL; this = this->next)
345 >        for (this = head.next; this != NULL; this = this->next)
346                  if (TOOSMALL(this)) {
347                          last->next = this->next;
348 <                        buddy = findbuddy(this, donelist);
348 >                        buddy = findbuddy(this, head.next);
349                          if (buddy != NULL)
350                                  mergesource(buddy, this);
351                          else
# Line 352 | Line 361 | absorb(s)                      /* absorb a source into indirect */
361   register struct source  *s;
362   {
363          FVECT   dir;
364 <        register int    i, n;
364 >        double  d;
365 >        register int    i;
366  
367          for (i = 0; i < nglardirs; i++) {
368                  spinvector(dir, ourview.vdir, ourview.vup, indirect[i].theta);
369 <                n = DOT(dir,s->dir)*s->dom*(sampdens*sampdens) + 0.5;
370 <                if (n == 0)
369 >                d = DOT(dir,s->dir)*s->dom*(sampdens*sampdens);
370 >                if (d <= 0.0)
371                          continue;
372 <                indirect[i].sum += n * s->brt;
373 <                indirect[i].n += n;
372 >                indirect[i].sum += d * s->brt;
373 >                indirect[i].n += d;
374          }
375          for ( ; s->first != NULL; s->first = s->first->next)
376                  free((char *)s->first);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines