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

Comparing ray/src/rt/rcontrib.c (file contents):
Revision 2.2 by greg, Sun Jun 10 05:25:42 2012 UTC vs.
Revision 2.5 by greg, Wed Jun 13 00:16:42 2012 UTC

# Line 25 | Line 25 | void   (*trace)() = trace_contrib;
25  
26   int     do_irrad = 0;                   /* compute irradiance? */
27  
28 < int     rand_samp = 0;                  /* pure Monte Carlo sampling? */
28 > int     rand_samp = 1;                  /* pure Monte Carlo sampling? */
29  
30   double  dstrsrc = 0.0;                  /* square source distribution */
31   double  shadthresh = .03;               /* shadow threshold */
# Line 45 | Line 45 | double specjitter = 1.;                /* specular sampling jitter *
45  
46   int     backvis = 1;                    /* back face visibility */
47  
48 < int     maxdepth = 8;                   /* maximum recursion depth */
49 < double  minweight = 5e-4;               /* minimum ray weight */
48 > int     maxdepth = -10;                 /* maximum recursion depth */
49 > double  minweight = 2e-3;               /* minimum ray weight */
50  
51   char    *ambfile = NULL;                /* ambient file name */
52   COLOR   ambval = BLKCOLOR;              /* ambient value */
# Line 63 | Line 63 | int    account;                        /* current accumulation count */
63   RNUMBER raysleft;                       /* number of rays left to trace */
64   long    waitflush;                      /* how long until next flush */
65  
66 < int     lastray = 0;                    /* last ray number sent */
67 < int     lastdone = 0;                   /* last ray output */
66 > RNUMBER lastray = 0;                    /* last ray number sent */
67 > RNUMBER lastdone = 0;                   /* last ray output */
68  
69 /* Close output stream and free record */
70 static void
71 closestream(void *p)
72 {
73        STREAMOUT       *sop = (STREAMOUT *)p;
74        int             status = 0;
75        if (sop->outpipe)
76                status = pclose(sop->ofp);
77        else if (sop->ofp != stdout)
78                status = fclose(sop->ofp);
79        if (status)
80                error(SYSTEM, "error closing output stream");
81        free(p);
82 }
83
84 LUTAB   ofiletab = LU_SINIT(free,closestream);  /* output file table */
85
86 #define OF_MODIFIER     01
87 #define OF_BIN          02
88
69   static void mcfree(void *p) { epfree((*(MODCONT *)p).binv); free(p); }
70  
71   LUTAB   modconttab = LU_SINIT(NULL,mcfree);     /* modifier lookup table */
# Line 232 | Line 212 | rcinit()
212          if ((nproc > 1) & (accumulate <= 0))
213                  put_zero_record(0);     /* prime our queue to accumulate */
214  
235        if (recover) {                  /* recover previous output? */
236                if (accumulate <= 0) {
237                        reload_output();
238                        if (nproc > 1)
239                                queue_modifiers();
240                } else
241                        recover_output();
242        }
215          if (yres > 0) {                 /* set up flushing & ray counts */
216                  if (xres > 0)
217                          raysleft = (RNUMBER)xres*yres;
# Line 254 | Line 226 | rcinit()
226          for (i = 0; i < nsources; i++)
227                  source[i].sflags |= SFOLLOW;
228  
229 <        if (nproc == 1 || in_rchild())  /* single process or child */
229 >        if (nproc > 1 && in_rchild())   /* forked child? */
230                  return;                 /* return to main processing loop */
231  
232 +        if (recover) {                  /* recover previous output? */
233 +                if (accumulate <= 0) {
234 +                        reload_output();
235 +                        if (nproc > 1)
236 +                                queue_modifiers();
237 +                } else
238 +                        recover_output();
239 +        }
240 +        if (nproc == 1)                 /* single process? */
241 +                return;
242 +
243          parental_loop();                /* else run controller */
244          quit(0);                        /* parent musn't return! */
245   }
# Line 370 | Line 353 | rcontrib()
353   #endif
354          while (getvec(orig) == 0 && getvec(direc) == 0) {
355                  d = normalize(direc);
356 <                if ((d == 0.0) & (accumulate != 1)) {
356 >                if (nchild != -1 && (d == 0.0) & (accumulate != 1)) {
357                          if (!ignore_warning_given++)
358                                  error(WARNING,
359                                  "dummy ray(s) ignored during accumulation\n");
# Line 382 | Line 365 | rcontrib()
365                  if (d == 0.0) {                         /* zero ==> flush */
366                          if ((yres <= 0) | (xres <= 0))
367                                  waitflush = 1;          /* flush right after */
368 +                        account = 1;
369                  } else {                                /* else compute */
370                          eval_ray(orig, direc, lim_dist ? d : 0.0);
371                  }
# Line 390 | Line 374 | rcontrib()
374                  if (raysleft && !--raysleft)
375                          break;          /* preemptive EOI */
376          }
377 <        if (accumulate <= 0 || account < accumulate) {
377 >        if (nchild != -1 && (accumulate <= 0) | (account < accumulate)) {
378                  if (account < accumulate) {
379                          error(WARNING, "partial accumulation in final record");
380                          accumulate -= account;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines