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.15 by greg, Wed May 1 11:17:01 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1990 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 107 | Line 118 | int  mod;
118   {
119          static int  depth = 0;
120          register OBJREC  *m;
121 +                                        /* check for irradiance calc. */
122 +        if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS))) {
123 +                if (irr_ignore(objptr(mod)->otype))
124 +                        raytrans(r);
125 +                else
126 +                        (*ofun[Lamb.otype].funp)(&Lamb, r);
127 +                return;
128 +        }
129                                          /* check for infinite loop */
130          if (depth++ >= MAXLOOP)
131                  objerror(r->ro, USER, "possible modifier loop");
# Line 230 | Line 249 | register RAY  *r;
249                  newdot = -newdot;
250          }
251          return(newdot);
252 + }
253 +
254 +
255 + newrayxf(r)                     /* get new tranformation matrix for ray */
256 + RAY  *r;
257 + {
258 +        static struct xfn {
259 +                struct xfn  *next;
260 +                FULLXF  xf;
261 +        }  xfseed = { &xfseed }, *xflast = &xfseed;
262 +        register struct xfn  *xp;
263 +        register RAY  *rp;
264 +
265 +        /*
266 +         * Search for transform in circular list that
267 +         * has no associated ray in the tree.
268 +         */
269 +        xp = xflast;
270 +        for (rp = r->parent; rp != NULL; rp = rp->parent)
271 +                if (rp->rox == &xp->xf) {               /* xp in use */
272 +                        xp = xp->next;                  /* move to next */
273 +                        if (xp == xflast) {             /* need new one */
274 +                                xp = (struct xfn *)bmalloc(sizeof(struct xfn));
275 +                                if (xp == NULL)
276 +                                        error(SYSTEM,
277 +                                                "out of memory in newrayxf");
278 +                                                        /* insert in list */
279 +                                xp->next = xflast->next;
280 +                                xflast->next = xp;
281 +                                break;                  /* we're done */
282 +                        }
283 +                        rp = r;                 /* start check over */
284 +                }
285 +                                        /* got it */
286 +        r->rox = &xp->xf;
287 +        xflast = xp;
288   }
289  
290  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines