ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rtrace.c
(Generate patch)

Comparing ray/src/rt/rtrace.c (file contents):
Revision 1.7 by greg, Thu Jan 4 11:16:05 1990 UTC vs.
Revision 1.14 by greg, Tue May 21 17:41:23 1991 UTC

# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20   *  All values default to ascii representation of real
21   *  numbers.  Binary representations can be selected
22   *  with '-ff' for float or '-fd' for double.  By default,
23 < *  radiance is computed.  The '-i' option indicates that
23 > *  radiance is computed.  The '-i' or '-I' options indicate that
24   *  irradiance values are desired.
25   */
26  
27   #include  "ray.h"
28  
29 + #include  "octree.h"
30 +
31   #include  "otypes.h"
32  
33 + int  dimlist[MAXDIM];                   /* sampling dimensions */
34 + int  ndims = 0;                         /* number of sampling dimensions */
35 + int  samplendx = 0;                     /* index for this sample */
36 +
37 + int  imm_irrad = 0;                     /* compute immediate irradiance? */
38 +
39   int  inform = 'a';                      /* input format */
40   int  outform = 'a';                     /* output format */
41   char  *outvals = "v";                   /* output specification */
# Line 51 | Line 59 | int  ambounce = 0;                     /* ambient bounces */
59   char  *amblist[128];                    /* ambient include/exclude list */
60   int  ambincl = -1;                      /* include == 1, exclude == 0 */
61  
62 + extern OBJREC  Lamb;                    /* a Lambertian surface */
63 +
64   static RAY  thisray;                    /* for our convenience */
65  
66 < extern int  oputo(), oputd(), oputv(), oputl(),
66 > static int  oputo(), oputd(), oputv(), oputl(),
67                  oputp(), oputn(), oputs(), oputw(), oputm();
68  
69   static int  (*ray_out[10])(), (*every_out[10])();
70 + static int  castonly;
71  
72 < extern int  puta(), putf(), putd();
72 > static int  puta(), putf(), putd();
73  
74   static int  (*putreal)();
75  
# Line 99 | Line 110 | char  *fname;
110                          fflush(stdout);
111                          continue;
112                  }
113 +                samplendx++;
114                                                          /* compute and print */
115 <                if (outvals[0] == 'i')
115 >                if (imm_irrad)
116                          irrad(orig, direc);
117                  else
118 <                        radiance(orig, direc);
118 >                        traceray(orig, direc);
119                                                          /* flush if time */
120                  if (--nextflush == 0) {
121                          fflush(stdout);
# Line 126 | Line 138 | register char  *vs;
138          extern int  ourtrace(), (*trace)();
139          register int (**table)() = ray_out;
140  
141 +        castonly = 1;
142          while (*vs)
143                  switch (*vs++) {
144                  case 't':                               /* trace */
145                          *table = NULL;
146                          table = every_out;
147                          trace = ourtrace;
148 +                        castonly = 0;
149                          break;
150                  case 'o':                               /* origin */
151                          *table++ = oputo;
# Line 141 | Line 155 | register char  *vs;
155                          break;
156                  case 'v':                               /* value */
157                          *table++ = oputv;
158 +                        castonly = 0;
159                          break;
160                  case 'l':                               /* length */
161                          *table++ = oputl;
162 +                        castonly = 0;
163                          break;
164                  case 'p':                               /* point */
165                          *table++ = oputp;
# Line 165 | Line 181 | register char  *vs;
181   }
182  
183  
184 < radiance(org, dir)              /* compute radiance value */
184 > traceray(org, dir)              /* compute and print ray value(s) */
185   FVECT  org, dir;
186   {
187          register int  (**tp)();
# Line 173 | Line 189 | FVECT  org, dir;
189          VCOPY(thisray.rorg, org);
190          VCOPY(thisray.rdir, dir);
191          rayorigin(&thisray, NULL, PRIMARY, 1.0);
192 <        rayvalue(&thisray);
192 >        if (castonly)
193 >                localhit(&thisray, &thescene) || sourcehit(&thisray);
194 >        else
195 >                rayvalue(&thisray);
196  
197          if (ray_out[0] == NULL)
198                  return;
# Line 184 | Line 203 | FVECT  org, dir;
203   }
204  
205  
206 < irrad(org, dir)                 /* compute irradiance value */
206 > irrad(org, dir)                 /* compute immediate irradiance value */
207   FVECT  org, dir;
208   {
190        static double  Lambfa[5] = {PI, PI, PI, 0.0, 0.0};
191        static OBJREC  Lamb = {
192                OVOID, MAT_PLASTIC, "Lambertian",
193                {0, 5, NULL, Lambfa}, NULL, -1,
194        };
209          register int  i;
210  
211          for (i = 0; i < 3; i++) {
# Line 226 | Line 240 | FILE  *fp;
240                          return(-1);
241                  break;
242          case 'f':                                       /* binary float */
243 <                if (fread(vf, sizeof(float), 3, fp) != 3)
243 >                if (fread((char *)vf, sizeof(float), 3, fp) != 3)
244                          return(-1);
245                  vec[0] = vf[0]; vec[1] = vf[1]; vec[2] = vf[2];
246                  break;
247          case 'd':                                       /* binary double */
248 <                if (fread(vec, sizeof(double), 3, fp) != 3)
248 >                if (fread((char *)vec, sizeof(double), 3, fp) != 3)
249                          return(-1);
250                  break;
251          }
# Line 299 | Line 313 | static
313   oputl(r)                                /* print length */
314   register RAY  *r;
315   {
316 <        if (r->rot < FHUGE)
303 <                (*putreal)(r->rot);
304 <        else
305 <                (*putreal)(0.0);
316 >        (*putreal)(r->rt);
317   }
318  
319  
# Line 382 | Line 393 | static
393   putd(v)                         /* print binary double */
394   double  v;
395   {
396 <        fwrite(&v, sizeof(v), 1, stdout);
396 >        fwrite((char *)&v, sizeof(v), 1, stdout);
397   }
398  
399  
# Line 392 | Line 403 | double  v;
403   {
404          float f = v;
405  
406 <        fwrite(&f, sizeof(f), 1, stdout);
406 >        fwrite((char *)&f, sizeof(f), 1, stdout);
407   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines