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.27 by greg, Mon Dec 17 14:38:12 1990 UTC vs.
Revision 1.30 by greg, Mon Feb 11 08:43:48 1991 UTC

# Line 109 | Line 109 | register OBJREC  *so;
109          register int  i;
110          
111          src->sflags = 0;
112 +        src->aimsuccess = 2*AIMREQT-1;          /* bitch on second failure */
113          src->nhits = 1; src->ntests = 2;        /* start probability = 1/2 */
114          src->so = so;
115  
# Line 313 | Line 314 | char  *p;                      /* data for f */
314          extern double  pow();
315          register int  sn;
316          int  nshadcheck, ncnts;
317 <        double  prob, ourthresh, hwt, test2, hit2;
317 >        int  nhits;
318 >        double  prob, ourthresh, hwt;
319          RAY  sr;
320                          /* NOTE: srccnt and cntord global so no recursion */
321          if (nsources <= 0)
# Line 336 | Line 338 | char  *p;                      /* data for f */
338                  if (cntord[sn].brt <= 0.0)
339                          continue;
340                                                  /* compute intersection */
341 <                if (!( source[sn].sflags & SDISTANT ?
341 >                if (source[sn].sflags & SDISTANT ?
342                                  sourcehit(&sr) :
343                                  (*ofun[source[sn].so->otype].funp)
344 <                                (source[sn].so, &sr) )) {
344 >                                (source[sn].so, &sr)) {
345 >                        if (source[sn].aimsuccess >= 0)
346 >                                source[sn].aimsuccess++;
347 >                } else {
348 >                        cntord[sn].brt = 0.0;
349 >                        if (source[sn].aimsuccess < 0)
350 >                                continue;       /* bitched already */
351 >                        source[sn].aimsuccess -= AIMREQT;
352 >                        if (source[sn].aimsuccess >= 0)
353 >                                continue;       /* leniency */
354                          sprintf(errmsg,
355                                  "aiming failure for light source \"%s\"",
356                                          source[sn].so->oname);
# Line 368 | Line 379 | char  *p;                      /* data for f */
379                                                  /* accumulate tail */
380          for (sn = ncnts-1; sn > 0; sn--)
381                  cntord[sn-1].brt += cntord[sn].brt;
371                                                /* start with prob=.5 */
372        hit2 = 0.5; test2 = 1.0;
382                                                  /* test for shadows */
383 +        nhits = 0;
384          for (sn = 0; sn < ncnts; sn++) {
385                                                  /* check threshold */
386                  if ((sn+nshadcheck>=ncnts ? cntord[sn].brt :
# Line 378 | Line 388 | char  *p;                      /* data for f */
388                                  < ourthresh*bright(r->rcol))
389                          break;
390                                                  /* get statistics */
381                hwt = (double)source[cntord[sn].sno].nhits /
382                                (double)source[cntord[sn].sno].ntests;
383                test2 += hwt;
391                  source[cntord[sn].sno].ntests++;
392                                                  /* test for hit */
393                  rayorigin(&sr, r, SHADOW, 1.0);
# Line 399 | Line 406 | char  *p;                      /* data for f */
406                  }
407                                                  /* add contribution if hit */
408                  addcolor(r->rcol, srccnt[cntord[sn].sno].val);
409 <                hit2 += hwt;
409 >                nhits++;
410                  source[cntord[sn].sno].nhits++;
411          }
412 <                                        /* weighted hit rate */
413 <        hwt = hit2 / test2;
412 >                                        /* surface hit rate */
413 >        if (sn > 0)
414 >                hwt = (double)nhits / (double)sn;
415 >        else
416 >                hwt = 0.5;
417   #ifdef DEBUG
418          sprintf(errmsg, "%d tested, %d untested, %f hit rate\n",
419                          sn, ncnts-sn, hwt);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines