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.33 by gwlarson, Tue Sep 15 09:52:39 1998 UTC vs.
Revision 2.34 by greg, Sat Feb 22 02:07:29 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  raytrace.c - routines for tracing and shading rays.
6   *
7 < *     8/7/85
7 > *  External symbols declared in ray.h
8   */
9  
10 + /* ====================================================================
11 + * The Radiance Software License, Version 1.0
12 + *
13 + * Copyright (c) 1990 - 2002 The Regents of the University of California,
14 + * through Lawrence Berkeley National Laboratory.   All rights reserved.
15 + *
16 + * Redistribution and use in source and binary forms, with or without
17 + * modification, are permitted provided that the following conditions
18 + * are met:
19 + *
20 + * 1. Redistributions of source code must retain the above copyright
21 + *         notice, this list of conditions and the following disclaimer.
22 + *
23 + * 2. Redistributions in binary form must reproduce the above copyright
24 + *       notice, this list of conditions and the following disclaimer in
25 + *       the documentation and/or other materials provided with the
26 + *       distribution.
27 + *
28 + * 3. The end-user documentation included with the redistribution,
29 + *           if any, must include the following acknowledgment:
30 + *             "This product includes Radiance software
31 + *                 (http://radsite.lbl.gov/)
32 + *                 developed by the Lawrence Berkeley National Laboratory
33 + *               (http://www.lbl.gov/)."
34 + *       Alternately, this acknowledgment may appear in the software itself,
35 + *       if and wherever such third-party acknowledgments normally appear.
36 + *
37 + * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
38 + *       and "The Regents of the University of California" must
39 + *       not be used to endorse or promote products derived from this
40 + *       software without prior written permission. For written
41 + *       permission, please contact [email protected].
42 + *
43 + * 5. Products derived from this software may not be called "Radiance",
44 + *       nor may "Radiance" appear in their name, without prior written
45 + *       permission of Lawrence Berkeley National Laboratory.
46 + *
47 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
48 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 + * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
51 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
54 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
55 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
56 + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
57 + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 + * SUCH DAMAGE.
59 + * ====================================================================
60 + *
61 + * This software consists of voluntary contributions made by many
62 + * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
63 + * information on Lawrence Berkeley National Laboratory, please see
64 + * <http://www.lbl.gov/>.
65 + */
66 +
67   #include  "ray.h"
68  
15 #include  "octree.h"
16
69   #include  "otypes.h"
70  
71   #include  "otspecial.h"
72  
73   #define  MAXCSET        ((MAXSET+1)*2-1)        /* maximum check set size */
74  
23 extern CUBE  thescene;                  /* our scene */
24 extern int  maxdepth;                   /* maximum recursion depth */
25 extern double  minweight;               /* minimum ray weight */
26 extern int  do_irrad;                   /* compute irradiance? */
27 extern COLOR  ambval;                   /* ambient value */
28
29 extern COLOR  cextinction;              /* global extinction coefficient */
30 extern COLOR  salbedo;                  /* global scattering albedo */
31 extern double  seccg;                   /* global scattering eccentricity */
32 extern double  ssampdist;               /* scatter sampling distance */
33
75   unsigned long  raynum = 0;              /* next unique ray number */
76   unsigned long  nrays = 0;               /* number of calls to localhit */
77  
# Line 42 | Line 83 | OBJREC  Lamb = {
83  
84   OBJREC  Aftplane;                       /* aft clipping plane object */
85  
86 < static int  raymove(), checkset(), checkhit();
86 > static int  raymove(), checkhit();
87 > static void  checkset();
88  
89   #ifndef  MAXLOOP
90   #define  MAXLOOP        0               /* modifier loop detection */
# Line 51 | Line 93 | static int  raymove(), checkset(), checkhit();
93   #define  RAYHIT         (-1)            /* return value for intercepted ray */
94  
95  
96 + int
97   rayorigin(r, ro, rt, rw)                /* start new ray from old one */
98   register RAY  *r, *ro;
99   int  rt;
# Line 101 | Line 144 | double  rw;
144   }
145  
146  
147 + void
148   rayclear(r)                     /* clear a ray for (re)evaluation */
149   register RAY  *r;
150   {
# Line 108 | Line 152 | register RAY  *r;
152          r->newcset = r->clipset;
153          r->robj = OVOID;
154          r->ro = NULL;
155 +        r->rox = NULL;
156          r->rt = r->rot = FHUGE;
157          r->pert[0] = r->pert[1] = r->pert[2] = 0.0;
158          setcolor(r->pcol, 1.0, 1.0, 1.0);
# Line 115 | Line 160 | register RAY  *r;
160   }
161  
162  
163 + void
164   raytrace(r)                     /* trace a ray and compute its value */
165   RAY  *r;
166   {
121        extern int  (*trace)();
122
167          if (localhit(r, &thescene))
168                  raycont(r);             /* hit local surface, evaluate */
169          else if (r->ro == &Aftplane) {
# Line 135 | Line 179 | RAY  *r;
179   }
180  
181  
182 + void
183   raycont(r)                      /* check for clipped object and continue */
184   register RAY  *r;
185   {
# Line 144 | Line 189 | register RAY  *r;
189   }
190  
191  
192 + void
193   raytrans(r)                     /* transmit ray as is */
194   register RAY  *r;
195   {
# Line 158 | Line 204 | register RAY  *r;
204   }
205  
206  
207 + int
208   rayshade(r, mod)                /* shade ray r with material mod */
209   register RAY  *r;
210   int  mod;
# Line 201 | Line 248 | int  mod;
248   }
249  
250  
251 + void
252   rayparticipate(r)                       /* compute ray medium participation */
253   register RAY  *r;
254   {
# Line 264 | Line 312 | int  mod;
312   }
313  
314  
315 + int
316   raymixture(r, fore, back, coef)         /* mix modifiers */
317   register RAY  *r;
318   OBJECT  fore, back;
# Line 364 | Line 413 | register RAY  *r;
413   }
414  
415  
416 + void
417   newrayxf(r)                     /* get new tranformation matrix for ray */
418   RAY  *r;
419   {
# Line 383 | Line 433 | RAY  *r;
433                  if (rp->rox == &xp->xf) {               /* xp in use */
434                          xp = xp->next;                  /* move to next */
435                          if (xp == xflast) {             /* need new one */
436 <                                xp = (struct xfn *)bmalloc(sizeof(struct xfn));
436 >                                xp = (struct xfn *)malloc(sizeof(struct xfn));
437                                  if (xp == NULL)
438                                          error(SYSTEM,
439                                                  "out of memory in newrayxf");
# Line 400 | Line 450 | RAY  *r;
450   }
451  
452  
453 + void
454   flipsurface(r)                  /* reverse surface orientation */
455   register RAY  *r;
456   {
# Line 413 | Line 464 | register RAY  *r;
464   }
465  
466  
467 + int
468   localhit(r, scene)              /* check for hit in the octree */
469   register RAY  *r;
470   register CUBE  *scene;
# Line 560 | Line 612 | register CUBE  *cu;
612   }
613  
614  
615 < static
615 > static int
616   checkhit(r, cu, cxs)            /* check for hit in full cube */
617   register RAY  *r;
618   CUBE  *cu;
# Line 584 | Line 636 | OBJECT  *cxs;
636   }
637  
638  
639 < static
639 > static void
640   checkset(os, cs)                /* modify checked set and set to check */
641   register OBJECT  *os;                   /* os' = os - cs */
642   register OBJECT  *cs;                   /* cs' = cs + os */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines