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 2.47 by greg, Thu Mar 10 22:37:00 2005 UTC vs.
Revision 2.51 by greg, Thu May 26 06:55:22 2005 UTC

# Line 46 | Line 46 | extern OBJREC *                        /* find an object's actual material
46   findmaterial(register OBJREC *o)
47   {
48          while (!ismaterial(o->otype)) {
49                if (ismixture(o->otype))
50                        return(NULL);   /* reject mixed materials */
49                  if (o->otype == MOD_ALIAS && o->oargs.nsargs) {
50                          OBJECT  aobj;
51                          OBJREC  *ao;
# Line 62 | Line 60 | findmaterial(register OBJREC *o)
60                          return(NULL);
61                  o = objptr(o->omod);
62          }
63 <        return(o);
63 >        return(o);              /* mixtures will return NULL */
64   }
65  
66  
# Line 179 | Line 177 | srcray(                                /* send a ray to a source, return domega */
177      double  d;                          /* distance to source */
178      register SRCREC  *srcp;
179  
180 <    rayorigin(sr, r, SHADOW, 1.0);              /* ignore limits */
180 >    rayorigin(sr, SHADOW, r, NULL);             /* ignore limits */
181  
182      while ((d = nextssamp(sr, si)) != 0.0) {
183          sr->rsrc = si->sn;                      /* remember source */
# Line 395 | Line 393 | direct(                                        /* add direct component */
393                  }
394   #endif
395                  VCOPY(scp->dir, sr.rdir);
396 +                copycolor(sr.rcoef, scp->coef);
397                                                  /* compute potential */
398                  sr.revf = srcvalue;
399                  rayvalue(&sr);
400 +                multcolor(sr.rcol, sr.rcoef);
401                  copycolor(scp->val, sr.rcol);
402                multcolor(scp->val, scp->coef);
402                  cntord[sn].brt = bright(scp->val);
403          }
404                                                  /* sort contributions */
# Line 438 | Line 437 | direct(                                        /* add direct component */
437                          break;
438                  scp = srccnt + cntord[sn].sndx;
439                                                  /* test for hit */
440 <                rayorigin(&sr, r, SHADOW, 1.0);
440 >                rayorigin(&sr, SHADOW, r, scp->coef);
441                  VCOPY(sr.rdir, scp->dir);
442                  sr.rsrc = scp->sno;
443                                                  /* keep statistics */
# Line 451 | Line 450 | direct(                                        /* add direct component */
450                                  source[scp->sno].sflags & SFOLLOW )) {
451                                                  /* follow entire path */
452                          raycont(&sr);
454                        rayparticipate(&sr);
453                          if (trace != NULL)
454                                  (*trace)(&sr);  /* trace execution */
455 +                        rayparticipate(&sr);
456                          if (bright(sr.rcol) <= FTINY) {
457   #if SHADCACHE
458                                  if ((scp <= srccnt || scp[-1].sno != scp->sno)
# Line 463 | Line 462 | direct(                                        /* add direct component */
462   #endif
463                                  continue;       /* missed! */
464                          }
465 +                        multcolor(sr.rcol, sr.rcoef);
466                          copycolor(scp->val, sr.rcol);
467 <                        multcolor(scp->val, scp->coef);
467 >                } else if (trace != NULL &&
468 >                        (source[scp->sno].sflags & (SDISTANT|SVIRTUAL|SFOLLOW))
469 >                                                == (SDISTANT|SFOLLOW) &&
470 >                                sourcehit(&sr) && rayshade(&sr, sr.ro->omod)) {
471 >                        (*trace)(&sr);          /* trace execution */
472 >                        /* skip call to rayparticipate() & scp->val update */
473                  }
474                                                  /* add contribution if hit */
475                  addcolor(r->rcol, scp->val);
# Line 486 | Line 491 | direct(                                        /* add direct component */
491                  scp = srccnt + cntord[sn].sndx;
492                  prob = hwt * (double)source[scp->sno].nhits /
493                                  (double)source[scp->sno].ntests;
494 <                if (prob > 1.0)
495 <                        prob = 1.0;
491 <                scalecolor(scp->val, prob);
494 >                if (prob < 1.0)
495 >                        scalecolor(scp->val, prob);
496                  addcolor(r->rcol, scp->val);
497          }
498   }
# Line 667 | Line 671 | m_light(                               /* ray hit a light source */
671   )
672   {
673                                                  /* check for over-counting */
674 <        if (badcomponent(m, r))
674 >        if (badcomponent(m, r)) {
675 >                setcolor(r->rcoef, 0.0, 0.0, 0.0);
676                  return(1);
677 <        if (wrongsource(m, r))
677 >        }
678 >        if (wrongsource(m, r)) {
679 >                setcolor(r->rcoef, 0.0, 0.0, 0.0);
680                  return(1);
681 +        }
682                                                  /* check for passed illum */
683          if (passillum(m, r)) {
684                  if (m->oargs.nsargs && strcmp(m->oargs.sarg[0], VOIDID))
# Line 678 | Line 686 | m_light(                               /* ray hit a light source */
686                  raytrans(r);
687                  return(1);
688          }
689 +                                                /* check for invisibility */
690 +        if (srcignore(m, r)) {
691 +                setcolor(r->rcoef, 0.0, 0.0, 0.0);
692 +                return(1);
693 +        }
694                                          /* otherwise treat as source */
695                                                  /* check for behind */
696          if (r->rod < 0.0)
684                return(1);
685                                                /* check for invisibility */
686        if (srcignore(m, r))
697                  return(1);
698                                                  /* check for outside spot */
699          if (m->otype==MAT_SPOT && spotout(r, makespot(m)))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines