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.52 by greg, Tue Jun 21 15:06:50 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 (r->crtype & SHADOW)                 /* shadow commitment */
101 +                return(0);
102 +        if (maxdepth <= 0 && rc != NULL) {      /* Russian roulette */
103 +                if (minweight <= 0.0)
104 +                        error(USER, "zero ray weight in Russian roulette");
105 +                if (maxdepth < 0 && r->rlvl > -maxdepth)
106 +                        return(-1);             /* upper reflection limit */
107 +                if (r->rweight >= minweight)
108 +                        return(0);
109 +                if (frandom() < r->rweight/minweight)
110 +                        return(-1);
111 +                rw = minweight/r->rweight;      /* promote survivor */
112 +                scalecolor(r->rcoef, rw);
113 +                r->rweight = minweight;
114 +                return(0);
115 +        }
116          return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1);
117   }
118  
# Line 118 | Line 137 | rayclear(                      /* clear a ray for (re)evaluation */
137  
138  
139   extern void
140 < rayvalue(                       /* trace a ray and compute its value */
140 > raytrace(                       /* trace a ray and compute its value */
141          RAY  *r
142   )
143   {
# Line 329 | Line 348 | raydist(               /* compute (cumulative) ray distance */
348  
349   extern void
350   raycontrib(             /* compute (cumulative) ray contribution */
351 <        COLOR  rc,
351 >        double  rc[3],
352          const RAY  *r,
353          int  flags
354   )
355   {
356 <        COLOR   eext, ext1;
357 <        
339 <        setcolor(eext, 0., 0., 0.);
340 <        setcolor(rc, 1., 1., 1.);
356 >        double  eext[3];
357 >        int     i;
358  
359 +        eext[0] = eext[1] = eext[2] = 0.;
360 +        rc[0] = rc[1] = rc[2] = 1.;
361 +
362          while (r != NULL && r->crtype&flags) {
363 <                multcolor(rc, r->rcoef);
364 <                copycolor(ext1, r->cext);
365 <                scalecolor(ext1, r->rot);
366 <                addcolor(eext, ext1);
363 >                for (i = 3; i--; ) {
364 >                        rc[i] *= colval(r->rcoef,i);
365 >                        eext[i] += r->rot * colval(r->cext,i);
366 >                }
367                  r = r->parent;
368          }
369 <        if (intens(eext) > FTINY) {
370 <                setcolor(ext1,  exp(-colval(eext,RED)),
371 <                                exp(-colval(eext,GRN)),
352 <                                exp(-colval(eext,BLU)));
353 <                multcolor(rc, ext1);
354 <        }
369 >        for (i = 3; i--; )
370 >                rc[i] *= (eext[i] <= FTINY) ? 1. :
371 >                                (eext[i] > 300.) ? 0. : exp(-eext[i]);
372   }
373  
374  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines