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.8 by greg, Wed Mar 20 13:32:56 1991 UTC vs.
Revision 1.11 by greg, Wed Apr 10 15:59:10 1991 UTC

# Line 80 | Line 80 | analyze()                      /* analyze our scene */
80          }
81          free((char *)spanbr);
82          close_allsrcs();
83        absorb_specks();
83   }
84  
85  
# Line 92 | 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 124 | 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 340 | Line 339 | absorb_specks()                        /* eliminate too-small sources */
339                  fprintf(stderr, "%s: absorbing small sources...\n", progname);
340          head.next = donelist;
341          last = &head;
342 <        for (this = donelist; this != NULL; this = this->next)
342 >        for (this = head.next; this != NULL; this = this->next)
343                  if (TOOSMALL(this)) {
344                          last->next = this->next;
345 <                        buddy = findbuddy(this, donelist);
345 >                        buddy = findbuddy(this, head.next);
346                          if (buddy != NULL)
347                                  mergesource(buddy, this);
348                          else
# Line 359 | Line 358 | absorb(s)                      /* absorb a source into indirect */
358   register struct source  *s;
359   {
360          FVECT   dir;
361 <        register int    i, n;
361 >        double  d;
362 >        register int    i;
363  
364          for (i = 0; i < nglardirs; i++) {
365                  spinvector(dir, ourview.vdir, ourview.vup, indirect[i].theta);
366 <                n = DOT(dir,s->dir)*s->dom*(sampdens*sampdens) + 0.5;
367 <                if (n == 0)
366 >                d = DOT(dir,s->dir)*s->dom*(sampdens*sampdens);
367 >                if (d <= 0.0)
368                          continue;
369 <                indirect[i].sum += n * s->brt;
370 <                indirect[i].n += n;
369 >                indirect[i].sum += d * s->brt;
370 >                indirect[i].n += d;
371          }
372          for ( ; s->first != NULL; s->first = s->first->next)
373                  free((char *)s->first);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines