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.29 by gregl, Tue Dec 23 18:25:15 1997 UTC vs.
Revision 2.33 by gwlarson, Tue Sep 15 09:52:39 1998 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1996 Regents of the University of California */
1 > /* Copyright (c) 1998 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4 < static char SCCSid[] = "$SunId$ LBL";
4 > static char SCCSid[] = "$SunId$ SGI";
5   #endif
6  
7   /*
# Line 44 | Line 44 | OBJREC  Aftplane;                      /* aft clipping plane object */
44  
45   static int  raymove(), checkset(), checkhit();
46  
47 < #define  MAXLOOP        128             /* modifier loop detection */
47 > #ifndef  MAXLOOP
48 > #define  MAXLOOP        0               /* modifier loop detection */
49 > #endif
50  
51   #define  RAYHIT         (-1)            /* return value for intercepted ray */
52  
# Line 54 | Line 56 | register RAY  *r, *ro;
56   int  rt;
57   double  rw;
58   {
59 +        double  re;
60 +
61          if ((r->parent = ro) == NULL) {         /* primary ray */
62                  r->rlvl = 0;
63                  r->rweight = rw;
# Line 82 | Line 86 | double  rw;
86                  copycolor(r->albedo, ro->albedo);
87                  r->gecc = ro->gecc;
88                  r->slights = ro->slights;
85                r->rweight = ro->rweight * rw;
89                  r->crtype = ro->crtype | (r->rtype = rt);
90                  VCOPY(r->rorg, ro->rop);
91 +                r->rweight = ro->rweight * rw;
92 +                                                /* estimate absorption */
93 +                re = colval(ro->cext,RED) < colval(ro->cext,GRN) ?
94 +                                colval(ro->cext,RED) : colval(ro->cext,GRN);
95 +                if (colval(ro->cext,BLU) < re) re = colval(ro->cext,BLU);
96 +                if (re > 0.)
97 +                        r->rweight *= exp(-re*ro->rot);
98          }
99          rayclear(r);
100          return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1);
# Line 152 | Line 162 | rayshade(r, mod)               /* shade ray r with material mod */
162   register RAY  *r;
163   int  mod;
164   {
155        static int  depth = 0;
165          int  gotmat;
166          register OBJREC  *m;
167 + #if  MAXLOOP
168 +        static int  depth = 0;
169                                          /* check for infinite loop */
170          if (depth++ >= MAXLOOP)
171                  objerror(r->ro, USER, "possible modifier loop");
172 + #endif
173          r->rt = r->rot;                 /* set effective ray length */
174          for (gotmat = 0; !gotmat && mod != OVOID; mod = m->omod) {
175                  m = objptr(mod);
# Line 170 | Line 182 | int  mod;
182                                          /* hack for irradiance calculation */
183                  if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS))) {
184                          if (irr_ignore(m->otype)) {
185 + #if  MAXLOOP
186                                  depth--;
187 + #endif
188                                  raytrans(r);
189                                  return(1);
190                          }
# Line 180 | Line 194 | int  mod;
194                                          /* materials call raytexture */
195                  gotmat = (*ofun[m->otype].funp)(m, r);
196          }
197 + #if  MAXLOOP
198          depth--;
199 + #endif
200          return(gotmat);
201   }
202  
# Line 220 | Line 236 | raytexture(r, mod)                     /* get material modifiers */
236   RAY  *r;
237   int  mod;
238   {
223        static int  depth = 0;
239          register OBJREC  *m;
240 + #if  MAXLOOP
241 +        static int  depth = 0;
242                                          /* check for infinite loop */
243          if (depth++ >= MAXLOOP)
244                  objerror(r->ro, USER, "modifier loop");
245 + #endif
246                                          /* execute textures and patterns */
247          for ( ; mod != OVOID; mod = m->omod) {
248                  m = objptr(mod);
# Line 240 | Line 258 | int  mod;
258                          objerror(r->ro, USER, errmsg);
259                  }
260          }
261 + #if  MAXLOOP
262          depth--;                        /* end here */
263 + #endif
264   }
265  
266  
# Line 269 | Line 289 | double  coef;
289                  backmat = rayshade(&br, back);
290                                          /* check for transparency */
291          if (backmat ^ foremat)
292 <                if (backmat)
292 >                if (backmat && coef > FTINY)
293                          raytrans(&fr);
294 <                else
294 >                else if (foremat && coef < 1.0-FTINY)
295                          raytrans(&br);
296                                          /* mix perturbations */
297          for (i = 0; i < 3; i++)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines