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

Comparing ray/src/util/findglare.c (file contents):
Revision 1.10 by greg, Wed Mar 20 12:30:37 1991 UTC vs.
Revision 1.15 by greg, Fri Apr 5 14:26:47 1991 UTC

# Line 40 | Line 40 | int    hlim;                           /* central limit of horizontal */
40  
41   struct illum    *indirect;              /* array of indirect illuminances */
42  
43 + long    npixinvw;                       /* number of pixels in view */
44 + long    npixmiss;                       /* number of pixels missed */
45  
46 +
47   main(argc, argv)
48   int     argc;
49   char    *argv[];
# Line 223 | Line 226 | init()                         /* initialize global variables */
226          indirect = (struct illum *)calloc(nglardirs, sizeof(struct illum));
227          if (indirect == NULL)
228                  memerr("indirect illuminances");
229 +        npixinvw = npixmiss = 0L;
230          copystruct(&leftview, &ourview);
231          copystruct(&rightview, &ourview);
232          spinvector(leftview.vdir, ourview.vdir, ourview.vup, maxtheta);
# Line 276 | Line 280 | cleanup()                              /* close files, wait for children */
280                  close_pict();
281          if (octree != NULL)
282                  done_rtrace();
283 +        if (npixinvw < 100*npixmiss)
284 +                fprintf(stderr, "%s: warning -- missing %ld%% of samples\n",
285 +                                progname, 100L*npixmiss/npixinvw);
286   }
287  
288  
# Line 283 | Line 290 | compdir(vd, x, y)                      /* compute direction for x,y */
290   FVECT   vd;
291   int     x, y;
292   {
293 +        static int      cury = 10000;
294 +        static double   err, cmpval;
295 +        long    t;
296          FVECT   org;                    /* dummy variable */
297  
298          if (x <= -hlim)                 /* left region */
299                  return(viewray(org, vd, &leftview,
300 <                                (x+hlim)/(2.*sampdens)+.5,
301 <                                y/(2.*sampdens)+.5));
300 >                                (double)(x+hlim)/(2*sampdens)+.5,
301 >                                (double)y/(2*sampdens)+.5));
302          if (x >= hlim)                  /* right region */
303                  return(viewray(org, vd, &rightview,
304 <                                (x-hlim)/(2.*sampdens)+.5,
305 <                                y/(2.*sampdens)+.5));
306 <                                                /* central region */
307 <        if (viewray(org, vd, &ourview, .5, y/(2.*sampdens)+.5) < 0)
304 >                                (double)(x-hlim)/(2*sampdens)+.5,
305 >                                (double)y/(2*sampdens)+.5));
306 >                                        /* central region */
307 >                                /* avoid over-counting of poles */
308 >        if (cury != y) {
309 >                err = 0.0;
310 >                cmpval = sqrt(1.0 - (double)((long)y*y)/((long)vsize*vsize));
311 >                cury = y;
312 >        }
313 >        err += cmpval;
314 >        if (err <= 0.5)
315                  return(-1);
316 +        err -= 1.0;
317 +        if (viewray(org, vd, &ourview, .5, (double)y/(2*sampdens)+.5) < 0)
318 +                return(-1);
319          spinvector(vd, vd, ourview.vup, h_theta(x));
320          return(0);
321   }
# Line 328 | Line 348 | printillum()                   /* print out indirect illuminances */
348  
349          printf("BEGIN indirect illuminance\n");
350          for (i = 0; i < nglardirs; i++)
351 <                printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta,
352 <                                PI * indirect[i].sum / (double)indirect[i].n);
351 >                if (indirect[i].n > FTINY)
352 >                        printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta,
353 >                                        PI * indirect[i].sum / indirect[i].n);
354          printf("END indirect illuminance\n");
355   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines