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.53 by greg, Thu Jun 23 09:11:38 2005 UTC vs.
Revision 2.60 by greg, Sat Dec 12 00:03:42 2009 UTC

# Line 17 | Line 17 | static const char RCSid[] = "$Id$";
17  
18   #define  MAXCSET        ((MAXSET+1)*2-1)        /* maximum check set size */
19  
20 < unsigned long  raynum = 0;              /* next unique ray number */
21 < unsigned long  nrays = 0;               /* number of calls to localhit */
20 > RNUMBER  raynum = 0;            /* next unique ray number */
21 > RNUMBER  nrays = 0;             /* number of calls to localhit */
22  
23   static RREAL  Lambfa[5] = {PI, PI, PI, 0.0, 0.0};
24   OBJREC  Lamb = {
25          OVOID, MAT_PLASTIC, "Lambertian",
26 <        {0, 5, NULL, Lambfa}, NULL,
26 >        {NULL, Lambfa, 0, 5}, NULL
27   };                                      /* a Lambertian surface */
28  
29   OBJREC  Aftplane;                       /* aft clipping plane object */
# Line 93 | Line 93 | rayorigin(             /* start new ray from old one */
93                                  colval(ro->cext,RED) : colval(ro->cext,GRN);
94                  if (colval(ro->cext,BLU) < re) re = colval(ro->cext,BLU);
95                  re *= ro->rot;
96 <                if (re > 0.1)
97 <                        if (re > 92.)
96 >                if (re > 0.1) {
97 >                        if (re > 92.) {
98                                  r->rweight = 0.0;
99 <                        else
99 >                        } else {
100                                  r->rweight *= exp(-re);
101 +                        }
102 +                }
103          }
104          rayclear(r);
105          if (r->rweight <= 0.0)                  /* check for expiration */
# Line 111 | Line 113 | rayorigin(             /* start new ray from old one */
113                          return(-1);             /* upper reflection limit */
114                  if (r->rweight >= minweight)
115                          return(0);
116 <                if (frandom() < r->rweight/minweight)
116 >                if (frandom() > r->rweight/minweight)
117                          return(-1);
118                  rw = minweight/r->rweight;      /* promote survivor */
119                  scalecolor(r->rcoef, rw);
120                  r->rweight = minweight;
121                  return(0);
122          }
123 <        return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1);
123 >        return(r->rlvl <= abs(maxdepth) && r->rweight >= minweight ? 0 : -1);
124   }
125  
126  
# Line 301 | Line 303 | raymixture(            /* mix modifiers */
303          foremat = backmat = 0;
304                                          /* foreground */
305          fr = *r;
306 <        if (coef > FTINY)
306 >        if (coef > FTINY) {
307 >                fr.rweight *= coef;
308 >                scalecolor(fr.rcoef, coef);
309                  foremat = rayshade(&fr, fore);
310 +        }
311                                          /* background */
312          br = *r;
313 <        if (coef < 1.0-FTINY)
313 >        if (coef < 1.0-FTINY) {
314 >                br.rweight *= 1.0-coef;
315 >                scalecolor(br.rcoef, 1.0-coef);
316                  backmat = rayshade(&br, back);
317 +        }
318                                          /* check for transparency */
319          if (backmat ^ foremat) {
320                  if (backmat && coef > FTINY)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines