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

Comparing ray/src/rt/source.c (file contents):
Revision 1.9 by greg, Thu Jun 8 09:35:43 1989 UTC vs.
Revision 1.10 by greg, Thu Jun 8 17:04:43 1989 UTC

# Line 304 | Line 304 | char  *p;                      /* data for f */
304          register int  sn;
305          register CONTRIB  *srccnt;
306          register CNTPTR  *cntord;
307 <        int  ncnts;
308 <        double  ourthresh, prob, hwt, test2, hit2;
307 >        double  prob, ourthresh, hwt, test2, hit2;
308          RAY  sr;
309  
310          srccnt = (CONTRIB *)malloc(nsources*sizeof(CONTRIB));
# Line 341 | Line 340 | char  *p;                      /* data for f */
340                                                  /* sort contributions */
341          qsort(cntord, nsources, sizeof(CNTPTR), cntcmp);
342          hit2 = 0.0; test2 = FTINY;
343 <                                                /* find last */
344 <        sn = 0; ncnts = nsources;
345 <        while (sn < ncnts-1) {
346 <                register int  m;
348 <                m = (sn + ncnts) >> 1;
349 <                if (cntord[m].brt > 0.0)
350 <                        sn = m;
351 <                else
352 <                        ncnts = m;
353 <        }
354 <                                                /* accumulate tail */
355 <        for (sn = ncnts-1; sn > 0; sn--)
356 <                cntord[sn-1].brt += cntord[sn].brt;
357 <                                                /* shadow testing */
358 <        for (sn = 0; sn < ncnts; sn++) {
359 <                                                /* tail below threshold? */
360 <                if (cntord[sn].brt < ourthresh*bright(r->rcol))
343 >                                                /* test for shadows */
344 >        for (sn = 0; sn < nsources; sn++) {
345 >                                                /* check threshold */
346 >                if (cntord[sn].brt <= ourthresh*bright(r->rcol))
347                          break;
348                                                  /* get statistics */
349                  hwt = (double)source[cntord[sn].sno].nhits /
# Line 389 | Line 375 | char  *p;                      /* data for f */
375                                          /* weighted hit rate */
376          hwt = hit2 / test2;
377   #ifdef DEBUG
378 <        fprintf(stderr, "%d tested, %d untested, %f hit rate\n",
379 <                        sn, ncnts-sn, hwt);
378 >        {
379 >                int  ntested = sn;
380   #endif
381                                          /* add in untested sources */
382 <        for ( ; sn < ncnts; sn++) {
382 >        for ( ; sn < nsources; sn++) {
383 >                if (cntord[sn].brt <= 0.0)
384 >                        break;
385                  prob = hwt * (double)source[cntord[sn].sno].nhits /
386                                  (double)source[cntord[sn].sno].ntests;
387                  scalecolor(srccnt[cntord[sn].sno].val, prob);
388                  addcolor(r->rcol, srccnt[cntord[sn].sno].val);
389          }
390 + #ifdef DEBUG
391 +        fprintf(stderr, "%d tested, %d untested, %f hit rate\n",
392 +                        ntested, sn-ntested, hwt);
393 +        }
394 + #endif
395 +                
396          free(srccnt);
397          free(cntord);
398   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines