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.3 by greg, Wed Jun 7 08:35:23 1989 UTC vs.
Revision 1.11 by greg, Sat Aug 18 10:34:47 1990 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16   *      xorg    yorg    zorg    xdir    ydir    zdir
17   *
18   *  The direction need not be normalized.  Output is flexible.
19 + *  If the direction vector is (0,0,0), then the output is flushed.
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,
# Line 25 | Line 26 | static char SCCSid[] = "$SunId$ LBL";
26  
27   #include  "ray.h"
28  
29 + #include  "octree.h"
30 +
31   #include  "otypes.h"
32  
33   int  inform = 'a';                      /* input format */
# Line 35 | Line 38 | int  hresolu = 0;                      /* horizontal (scan) size */
38   int  vresolu = 0;                       /* vertical resolution */
39  
40   double  dstrsrc = 0.0;                  /* square source distribution */
41 < double  shadthresh = .01;               /* shadow threshold */
41 > double  shadthresh = .05;               /* shadow threshold */
42 > double  shadcert = .5;                  /* shadow certainty */
43  
44   int  maxdepth = 6;                      /* maximum recursion depth */
45   double  minweight = 4e-3;               /* minimum ray weight */
46  
47   COLOR  ambval = BLKCOLOR;               /* ambient value */
48   double  ambacc = 0.2;                   /* ambient accuracy */
49 < int  ambres = 128;                      /* ambient resolution */
49 > int  ambres = 32;                       /* ambient resolution */
50   int  ambdiv = 128;                      /* ambient divisions */
51   int  ambssamp = 0;                      /* ambient super-samples */
52   int  ambounce = 0;                      /* ambient bounces */
# Line 51 | Line 55 | int  ambincl = -1;                     /* include == 1, exclude == 0 */
55  
56   static RAY  thisray;                    /* for our convenience */
57  
58 < extern int  oputo(), oputd(), oputv(), oputl(),
58 > static int  oputo(), oputd(), oputv(), oputl(),
59                  oputp(), oputn(), oputs(), oputw(), oputm();
60  
61   static int  (*ray_out[10])(), (*every_out[10])();
62 + static int  castonly;
63  
64 < extern int  puta(), putf(), putd();
64 > static int  puta(), putf(), putd();
65  
66   static int  (*putreal)();
67  
# Line 93 | Line 98 | char  *fname;
98          while (getvec(orig, inform, fp) == 0 &&
99                          getvec(direc, inform, fp) == 0) {
100  
101 <                if (normalize(direc) == 0.0)
102 <                        error(USER, "zero direction vector");
101 >                if (normalize(direc) == 0.0) {          /* zero ==> flush */
102 >                        fflush(stdout);
103 >                        continue;
104 >                }
105                                                          /* compute and print */
106                  if (outvals[0] == 'i')
107                          irrad(orig, direc);
108                  else
109                          radiance(orig, direc);
110 <                                                        /* flush if requested */
110 >                                                        /* flush if time */
111                  if (--nextflush == 0) {
112                          fflush(stdout);
113                          nextflush = hresolu;
# Line 122 | Line 129 | register char  *vs;
129          extern int  ourtrace(), (*trace)();
130          register int (**table)() = ray_out;
131  
132 +        castonly = 1;
133          while (*vs)
134                  switch (*vs++) {
135                  case 't':                               /* trace */
136                          *table = NULL;
137                          table = every_out;
138                          trace = ourtrace;
139 +                        castonly = 0;
140                          break;
141                  case 'o':                               /* origin */
142                          *table++ = oputo;
# Line 137 | Line 146 | register char  *vs;
146                          break;
147                  case 'v':                               /* value */
148                          *table++ = oputv;
149 +                        castonly = 0;
150                          break;
151                  case 'l':                               /* length */
152                          *table++ = oputl;
153 +                        castonly = 0;
154                          break;
155                  case 'p':                               /* point */
156                          *table++ = oputp;
# Line 169 | Line 180 | FVECT  org, dir;
180          VCOPY(thisray.rorg, org);
181          VCOPY(thisray.rdir, dir);
182          rayorigin(&thisray, NULL, PRIMARY, 1.0);
183 <        rayvalue(&thisray);
183 >        if (castonly)
184 >                localhit(&thisray, &thescene) || sourcehit(&thisray);
185 >        else
186 >                rayvalue(&thisray);
187  
188          if (ray_out[0] == NULL)
189                  return;
# Line 222 | Line 236 | FILE  *fp;
236                          return(-1);
237                  break;
238          case 'f':                                       /* binary float */
239 <                if (fread(vf, sizeof(float), 3, fp) != 3)
239 >                if (fread((char *)vf, sizeof(float), 3, fp) != 3)
240                          return(-1);
241                  vec[0] = vf[0]; vec[1] = vf[1]; vec[2] = vf[2];
242                  break;
243          case 'd':                                       /* binary double */
244 <                if (fread(vec, sizeof(double), 3, fp) != 3)
244 >                if (fread((char *)vec, sizeof(double), 3, fp) != 3)
245                          return(-1);
246                  break;
247          }
# Line 295 | Line 309 | static
309   oputl(r)                                /* print length */
310   register RAY  *r;
311   {
312 <        if (r->rot < FHUGE)
299 <                (*putreal)(r->rot);
300 <        else
301 <                (*putreal)(0.0);
312 >        (*putreal)(r->rt);
313   }
314  
315  
# Line 378 | Line 389 | static
389   putd(v)                         /* print binary double */
390   double  v;
391   {
392 <        fwrite(&v, sizeof(v), 1, stdout);
392 >        fwrite((char *)&v, sizeof(v), 1, stdout);
393   }
394  
395  
# Line 388 | Line 399 | double  v;
399   {
400          float f = v;
401  
402 <        fwrite(&f, sizeof(f), 1, stdout);
402 >        fwrite((char *)&f, sizeof(f), 1, stdout);
403   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines