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.18 by greg, Wed May 29 11:09:23 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 118 | Line 129 | int  mod;
129                          error(USER, errmsg);
130                  }
131                  ******/
132 +                                        /* hack for irradiance calculation */
133 +                if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS))) {
134 +                        if (irr_ignore(m->otype)) {
135 +                                depth--;
136 +                                raytrans(r);
137 +                                return;
138 +                        }
139 +                        if (!islight(m->otype))
140 +                                m = &Lamb;
141 +                }
142                  (*ofun[m->otype].funp)(m, r);   /* execute function */
143                  m->lastrno = r->rno;
144                  if (ismaterial(m->otype)) {     /* materials call raytexture */
# Line 233 | Line 254 | register RAY  *r;
254   }
255  
256  
257 + newrayxf(r)                     /* get new tranformation matrix for ray */
258 + RAY  *r;
259 + {
260 +        static struct xfn {
261 +                struct xfn  *next;
262 +                FULLXF  xf;
263 +        }  xfseed = { &xfseed }, *xflast = &xfseed;
264 +        register struct xfn  *xp;
265 +        register RAY  *rp;
266 +
267 +        /*
268 +         * Search for transform in circular list that
269 +         * has no associated ray in the tree.
270 +         */
271 +        xp = xflast;
272 +        for (rp = r->parent; rp != NULL; rp = rp->parent)
273 +                if (rp->rox == &xp->xf) {               /* xp in use */
274 +                        xp = xp->next;                  /* move to next */
275 +                        if (xp == xflast) {             /* need new one */
276 +                                xp = (struct xfn *)bmalloc(sizeof(struct xfn));
277 +                                if (xp == NULL)
278 +                                        error(SYSTEM,
279 +                                                "out of memory in newrayxf");
280 +                                                        /* insert in list */
281 +                                xp->next = xflast->next;
282 +                                xflast->next = xp;
283 +                                break;                  /* we're done */
284 +                        }
285 +                        rp = r;                 /* start check over */
286 +                }
287 +                                        /* got it */
288 +        r->rox = &xp->xf;
289 +        xflast = xp;
290 + }
291 +
292 +
293   flipsurface(r)                  /* reverse surface orientation */
294   register RAY  *r;
295   {
# Line 265 | Line 322 | register CUBE  *scene;
322                  else if (r->rdir[i] < -FTINY)
323                          sflags |= 0x10 << i;
324          }
325 +        if (sflags == 0)
326 +                error(CONSISTENCY, "zero ray direction in localhit");
327          t = 0.0;
328          if (!incube(scene, curpos)) {
329                                          /* find distance to entry */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines