| 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[]; | 
| 50 | 
  | 
{ | 
| 51 | 
+ | 
        int     combine = 1; | 
| 52 | 
  | 
        int     gotview = 0; | 
| 53 | 
  | 
        int     rval, i; | 
| 54 | 
  | 
        char    *err; | 
| 102 | 
  | 
                case 'p': | 
| 103 | 
  | 
                        picture = argv[++i]; | 
| 104 | 
  | 
                        break; | 
| 105 | 
+ | 
                case 'c': | 
| 106 | 
+ | 
                        combine = !combine; | 
| 107 | 
+ | 
                        break; | 
| 108 | 
  | 
                case 'd': | 
| 109 | 
  | 
                case 'l': | 
| 110 | 
  | 
                        rtargv[rtargc++] = argv[i]; | 
| 183 | 
  | 
        if (threshold <= FTINY) | 
| 184 | 
  | 
                comp_thresh();                  /* compute glare threshold */ | 
| 185 | 
  | 
        analyze();                              /* analyze view */ | 
| 186 | 
+ | 
        if (combine) | 
| 187 | 
+ | 
                absorb_specks();                /* eliminate tiny sources */ | 
| 188 | 
  | 
        cleanup();                              /* tidy up */ | 
| 189 | 
  | 
                                                /* print header */ | 
| 190 | 
  | 
        printargs(argc, argv, stdout); | 
| 232 | 
  | 
        indirect = (struct illum *)calloc(nglardirs, sizeof(struct illum)); | 
| 233 | 
  | 
        if (indirect == NULL) | 
| 234 | 
  | 
                memerr("indirect illuminances"); | 
| 235 | 
+ | 
        npixinvw = npixmiss = 0L; | 
| 236 | 
  | 
        copystruct(&leftview, &ourview); | 
| 237 | 
  | 
        copystruct(&rightview, &ourview); | 
| 238 | 
  | 
        spinvector(leftview.vdir, ourview.vdir, ourview.vup, maxtheta); | 
| 286 | 
  | 
                close_pict(); | 
| 287 | 
  | 
        if (octree != NULL) | 
| 288 | 
  | 
                done_rtrace(); | 
| 289 | 
+ | 
        if (npixinvw < 100*npixmiss) | 
| 290 | 
+ | 
                fprintf(stderr, "%s: warning -- missing %ld%% of samples\n", | 
| 291 | 
+ | 
                                progname, 100L*npixmiss/npixinvw); | 
| 292 | 
  | 
} | 
| 293 | 
  | 
 | 
| 294 | 
  | 
 | 
| 296 | 
  | 
FVECT   vd; | 
| 297 | 
  | 
int     x, y; | 
| 298 | 
  | 
{ | 
| 299 | 
+ | 
        static int      cury = 10000; | 
| 300 | 
+ | 
        static double   err, cmpval; | 
| 301 | 
+ | 
        long    t; | 
| 302 | 
  | 
        FVECT   org;                    /* dummy variable */ | 
| 303 | 
  | 
 | 
| 304 | 
  | 
        if (x <= -hlim)                 /* left region */ | 
| 305 | 
  | 
                return(viewray(org, vd, &leftview, | 
| 306 | 
< | 
                                (x+hlim)/(2.*sampdens)+.5, | 
| 307 | 
< | 
                                y/(2.*sampdens)+.5)); | 
| 306 | 
> | 
                                (double)(x+hlim)/(2*sampdens)+.5, | 
| 307 | 
> | 
                                (double)y/(2*sampdens)+.5)); | 
| 308 | 
  | 
        if (x >= hlim)                  /* right region */ | 
| 309 | 
  | 
                return(viewray(org, vd, &rightview, | 
| 310 | 
< | 
                                (x-hlim)/(2.*sampdens)+.5, | 
| 311 | 
< | 
                                y/(2.*sampdens)+.5)); | 
| 312 | 
< | 
                                                /* central region */ | 
| 313 | 
< | 
        if (viewray(org, vd, &ourview, .5, y/(2.*sampdens)+.5) < 0) | 
| 310 | 
> | 
                                (double)(x-hlim)/(2*sampdens)+.5, | 
| 311 | 
> | 
                                (double)y/(2*sampdens)+.5)); | 
| 312 | 
> | 
                                        /* central region */ | 
| 313 | 
> | 
                                /* avoid over-counting of poles */ | 
| 314 | 
> | 
        if (cury != y) { | 
| 315 | 
> | 
                err = 0.0; | 
| 316 | 
> | 
                cmpval = sqrt(1.0 - (double)((long)y*y)/((long)vsize*vsize)); | 
| 317 | 
> | 
                cury = y; | 
| 318 | 
> | 
        } | 
| 319 | 
> | 
        err += cmpval; | 
| 320 | 
> | 
        if (err <= 0.5) | 
| 321 | 
> | 
                return(-1); | 
| 322 | 
> | 
        err -= 1.0; | 
| 323 | 
> | 
        if (viewray(org, vd, &ourview, .5, (double)y/(2*sampdens)+.5) < 0) | 
| 324 | 
  | 
                return(-1); | 
| 325 | 
  | 
        spinvector(vd, vd, ourview.vup, h_theta(x)); | 
| 326 | 
  | 
        return(0); |