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 2.44 by greg, Sun Jun 5 19:52:01 2005 UTC vs.
Revision 2.54 by greg, Wed Apr 5 14:30:38 2006 UTC

# Line 29 | Line 29 | static const char      RCSid[] = "$Id$";
29   #include  "source.h"
30   #include  "otypes.h"
31   #include  "resolu.h"
32 + #include  "random.h"
33  
34   CUBE  thescene;                         /* our scene */
35   OBJECT  nsceneobjs;                     /* number of objects in our scene */
# Line 46 | Line 47 | char  *outvals = "v";                  /* output specification */
47  
48   int  do_irrad = 0;                      /* compute irradiance? */
49  
50 + int  rand_samp = 1;                     /* pure Monte Carlo sampling? */
51 +
52   void  (*trace)() = NULL;                /* trace call */
53  
54   char  *tralist[128];                    /* list of modifers to trace (or no) */
55   int  traincl = -1;                      /* include == 1, exclude == 0 */
56 < #define  MAXTSET        511             /* maximum number in trace set */
56 > #ifndef  MAXTSET
57 > #define  MAXTSET        8192            /* maximum number in trace set */
58 > #endif
59   OBJECT  traset[MAXTSET+1]={0};          /* trace include/exclude set */
60  
61   int  hresolu = 0;                       /* horizontal (scan) size */
# Line 96 | Line 101 | typedef void putf_t(double v);
101   static putf_t puta, putd, putf;
102  
103   typedef void oputf_t(RAY *r);
104 < static oputf_t  oputo, oputd, oputv, oputl, oputL, oputc, oputp,
104 > static oputf_t  oputo, oputd, oputv, oputV, oputl, oputL, oputc, oputp,
105                  oputn, oputN, oputs, oputw, oputW, oputm, oputM, oputtilde;
106  
107   static void setoutput(char *vs);
# Line 148 | Line 153 | rtrace(                                /* trace rays from file */
153          char  *fname
154   )
155   {
156 <        long  vcount = hresolu>1 ? hresolu*vresolu : vresolu;
156 >        unsigned long  vcount = (hresolu > 1) ? (unsigned long)hresolu*vresolu
157 >                                              : vresolu;
158          long  nextflush = hresolu;
159          FILE  *fp;
160          double  d;
# Line 187 | Line 193 | rtrace(                                /* trace rays from file */
193                  d = normalize(direc);
194                  if (d == 0.0) {                         /* zero ==> flush */
195                          bogusray();
196 <                        if (--nextflush <= 0 || vcount <= 0) {
196 >                        if (--nextflush <= 0 || !vcount) {
197                                  fflush(stdout);
198                                  nextflush = hresolu;
199                          }
# Line 199 | Line 205 | rtrace(                                /* trace rays from file */
205                          else
206                                  rad(orig, direc, lim_dist ? d : 0.0);
207                                                          /* flush if time */
208 <                        if (--nextflush == 0) {
208 >                        if (!--nextflush) {
209                                  fflush(stdout);
210                                  nextflush = hresolu;
211                          }
212                  }
213                  if (ferror(stdout))
214                          error(SYSTEM, "write error");
215 <                if (--vcount == 0)                      /* check for end */
215 >                if (vcount && !--vcount)                /* check for end */
216                          break;
217          }
218 <        fflush(stdout);
219 <        if (vcount > 0)
218 >        if (fflush(stdout) < 0)
219 >                error(SYSTEM, "write error");
220 >        if (vcount)
221                  error(USER, "unexpected EOF on input");
222          if (fname != NULL)
223                  fclose(fp);
# Line 258 | Line 265 | setoutput(                             /* set up output tables */
265                          *table++ = oputv;
266                          castonly = 0;
267                          break;
268 +                case 'V':                               /* contribution */
269 +                        *table++ = oputV;
270 +                        if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0))
271 +                                error(WARNING,
272 +                                        "-otV accuracy depends on -aa 0 -as 0");
273 +                        break;
274                  case 'l':                               /* effective distance */
275                          *table++ = oputl;
276                          castonly = 0;
# Line 525 | Line 538 | oputv(                         /* print value */
538  
539  
540   static void
541 + oputV(                          /* print value contribution */
542 +        RAY *r
543 + )
544 + {
545 +        double  contr[3];
546 +
547 +        raycontrib(contr, r, PRIMARY);
548 +        multcolor(contr, r->rcol);
549 +        (*putreal)(contr[RED]);
550 +        (*putreal)(contr[GRN]);
551 +        (*putreal)(contr[BLU]);
552 + }
553 +
554 +
555 + static void
556   oputl(                          /* print effective distance */
557          RAY  *r
558   )
# Line 629 | Line 657 | oputw(                         /* print weight */
657  
658  
659   static void
660 < oputW(                          /* print contribution */
660 > oputW(                          /* print coefficient */
661          RAY  *r
662   )
663   {
664 <        COLOR   contr;
664 >        double  contr[3];
665  
666          raycontrib(contr, r, PRIMARY);
667 <        (*putreal)(colval(contr,RED));
668 <        (*putreal)(colval(contr,GRN));
669 <        (*putreal)(colval(contr,BLU));
667 >        (*putreal)(contr[RED]);
668 >        (*putreal)(contr[GRN]);
669 >        (*putreal)(contr[BLU]);
670   }
671  
672  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines