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

Comparing ray/src/rt/raytrace.c (file contents):
Revision 2.49 by greg, Tue Apr 19 01:15:06 2005 UTC vs.
Revision 2.51 by greg, Tue May 31 18:01:09 2005 UTC

# Line 13 | Line 13 | static const char RCSid[] = "$Id$";
13   #include  "source.h"
14   #include  "otypes.h"
15   #include  "otspecial.h"
16 + #include  "random.h"
17  
18   #define  MAXCSET        ((MAXSET+1)*2-1)        /* maximum check set size */
19  
# Line 58 | Line 59 | rayorigin(             /* start new ray from old one */
59                  r->crtype = r->rtype = rt;
60                  r->rsrc = -1;
61                  r->clipset = NULL;
62 +                r->revf = raytrace;
63                  copycolor(r->cext, cextinction);
64                  copycolor(r->albedo, salbedo);
65                  r->gecc = seccg;
# Line 78 | Line 80 | rayorigin(             /* start new ray from old one */
80                          r->clipset = ro->newcset;
81                          r->rmax = ro->rmax <= FTINY ? 0.0 : ro->rmax - ro->rot;
82                  }
83 +                r->revf = ro->revf;
84                  copycolor(r->cext, ro->cext);
85                  copycolor(r->albedo, ro->albedo);
86                  r->gecc = ro->gecc;
# Line 94 | Line 97 | rayorigin(             /* start new ray from old one */
97                          r->rweight *= exp(-re);
98          }
99          rayclear(r);
100 +        if (maxdepth <= 0 && rc != NULL) {      /* Russian roulette */
101 +                if (minweight <= 0.0)
102 +                        error(USER, "zero ray weight in Russian roulette");
103 +                if (maxdepth < 0 && r->rlvl > -maxdepth)
104 +                        return(-1);             /* upper reflection limit */
105 +                if (r->rweight >= minweight)
106 +                        return(0);
107 +                if (frandom() < r->rweight/minweight)
108 +                        return(-1);
109 +                rw = minweight/r->rweight;      /* promote survivor */
110 +                scalecolor(r->rcoef, rw);
111 +                r->rweight = minweight;
112 +                return(0);
113 +        }
114          return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1);
115   }
116  
# Line 118 | Line 135 | rayclear(                      /* clear a ray for (re)evaluation */
135  
136  
137   extern void
138 < rayvalue(                       /* trace a ray and compute its value */
138 > raytrace(                       /* trace a ray and compute its value */
139          RAY  *r
140   )
141   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines