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 1.11 by greg, Sat Aug 18 04:25:59 1990 UTC vs.
Revision 1.19 by greg, Fri Jun 14 10:34:26 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #include  "otypes.h"
18  
19 + #include  "otspecial.h"
20 +
21   extern CUBE  thescene;                  /* our scene */
22   extern int  maxdepth;                   /* maximum recursion depth */
23   extern double  minweight;               /* minimum ray weight */
24 + extern int  do_irrad;                   /* compute irradiance? */
25  
26   long  nrays = 0L;                       /* number of rays traced */
27  
28 + static double  Lambfa[5] = {PI, PI, PI, 0.0, 0.0};
29 + OBJREC  Lamb = {
30 +        OVOID, MAT_PLASTIC, "Lambertian",
31 +        {0, 5, NULL, Lambfa}, NULL, -1,
32 + };                                      /* a Lambertian surface */
33 +
34   #define  MAXLOOP        128             /* modifier loop detection */
35  
36   #define  RAYHIT         (-1)            /* return value for intercepted ray */
# Line 69 | Line 78 | RAY  *r;
78   {
79          extern int  (*trace)();
80  
81 <        if (localhit(r, &thescene) || sourcehit(r))
81 >        if (localhit(r, &thescene))
82                  raycont(r);
83 +        else if (sourcehit(r))
84 +                rayshade(r, r->ro->omod);
85  
86          if (trace != NULL)
87                  (*trace)(r);            /* trace execution */
# Line 110 | Line 121 | int  mod;
121                                          /* check for infinite loop */
122          if (depth++ >= MAXLOOP)
123                  objerror(r->ro, USER, "possible modifier loop");
124 +        r->rt = r->rot;                 /* set effective ray length */
125          for ( ; mod != OVOID; mod = m->omod) {
126                  m = objptr(mod);
127                  /****** unnecessary test since modifier() is always called
# Line 118 | Line 130 | int  mod;
130                          error(USER, errmsg);
131                  }
132                  ******/
133 +                                        /* hack for irradiance calculation */
134 +                if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS))) {
135 +                        if (irr_ignore(m->otype)) {
136 +                                depth--;
137 +                                raytrans(r);
138 +                                return;
139 +                        }
140 +                        if (!islight(m->otype))
141 +                                m = &Lamb;
142 +                }
143                  (*ofun[m->otype].funp)(m, r);   /* execute function */
144                  m->lastrno = r->rno;
145                  if (ismaterial(m->otype)) {     /* materials call raytexture */
# Line 233 | Line 255 | register RAY  *r;
255   }
256  
257  
258 + newrayxf(r)                     /* get new tranformation matrix for ray */
259 + RAY  *r;
260 + {
261 +        static struct xfn {
262 +                struct xfn  *next;
263 +                FULLXF  xf;
264 +        }  xfseed = { &xfseed }, *xflast = &xfseed;
265 +        register struct xfn  *xp;
266 +        register RAY  *rp;
267 +
268 +        /*
269 +         * Search for transform in circular list that
270 +         * has no associated ray in the tree.
271 +         */
272 +        xp = xflast;
273 +        for (rp = r->parent; rp != NULL; rp = rp->parent)
274 +                if (rp->rox == &xp->xf) {               /* xp in use */
275 +                        xp = xp->next;                  /* move to next */
276 +                        if (xp == xflast) {             /* need new one */
277 +                                xp = (struct xfn *)bmalloc(sizeof(struct xfn));
278 +                                if (xp == NULL)
279 +                                        error(SYSTEM,
280 +                                                "out of memory in newrayxf");
281 +                                                        /* insert in list */
282 +                                xp->next = xflast->next;
283 +                                xflast->next = xp;
284 +                                break;                  /* we're done */
285 +                        }
286 +                        rp = r;                 /* start check over */
287 +                }
288 +                                        /* got it */
289 +        r->rox = &xp->xf;
290 +        xflast = xp;
291 + }
292 +
293 +
294   flipsurface(r)                  /* reverse surface orientation */
295   register RAY  *r;
296   {
# Line 265 | Line 323 | register CUBE  *scene;
323                  else if (r->rdir[i] < -FTINY)
324                          sflags |= 0x10 << i;
325          }
326 +        if (sflags == 0)
327 +                error(CONSISTENCY, "zero ray direction in localhit");
328          t = 0.0;
329          if (!incube(scene, curpos)) {
330                                          /* find distance to entry */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines