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

Comparing ray/src/rt/rxcmain.cpp (file contents):
Revision 2.9 by greg, Tue Dec 3 17:39:42 2024 UTC vs.
Revision 2.13 by greg, Tue Dec 24 16:58:13 2024 UTC

# Line 56 | Line 56 | printdefaults(void)                    /* print default values to stdou
56          printf("-f%c%c\t\t\t\t# format input/output = %s/%s\n",
57                          inpfmt, outfmt, formstr(inpfmt), formstr(outfmt));
58          if (report_intvl > 0)
59 <                printf("-t %-9d\t\t\t#  time between reports\n", report_intvl);
59 >                printf("-t %-9d\t\t\t# time between reports\n", report_intvl);
60          printf(erract[WARNING].pf != NULL ?
61                          "-w+\t\t\t\t# warning messages on\n" :
62                          "-w-\t\t\t\t# warning messages off\n");
# Line 132 | Line 132 | fmterr:
132          error(USER, errmsg);
133   }
134  
135 + /* Set default options */
136 + static void
137 + default_options(void)
138 + {
139 +        rand_samp = 1;
140 +        dstrsrc = 0.9;
141 +        directrelay = 3;
142 +        vspretest = 512;
143 +        srcsizerat = .2;
144 +        specthresh = .02;
145 +        specjitter = 1.;
146 +        maxdepth = -10;
147 +        minweight = 2e-3;
148 +        ambres = 256;
149 +        ambdiv = 350;
150 +        ambounce = 1;
151 + }
152  
153   /* Set overriding options */
154   static void
# Line 142 | Line 159 | override_options(void)
159          ambacc = 0;
160   }
161  
145
162   int
163   main(int argc, char *argv[])
164   {
# Line 173 | Line 189 | main(int argc, char *argv[])
189                                          /* initialize calcomp routines early */
190          initfunc();
191          calcontext(RCCONTEXT);
192 +                                        /* set rcontrib defaults */
193 +        default_options();
194                                          /* option city */
195          for (i = 1; i < argc; i++) {
196                                                  /* expand arguments */
# Line 340 | Line 358 | main(int argc, char *argv[])
358          if (rval >= myRCmanager.GetRowMax()) {
359                  error(WARNING, "nothing left to compute");
360                  quit(0);
361 <        }                               // add processes as requested
344 <        myRCmanager.SetThreadCount(nproc);
345 <
361 >        }
362          rxcontrib(rval);                /* trace ray contributions (loop) */
363  
364          quit(0);        /* exit clean */
# Line 397 | Line 413 | getRayBundle(FVECT *orig_dir = NULL)
413          int     n2go = myRCmanager.accum;
414  
415          switch (inpfmt) {
416 <        case 'a':                               // ASCII input
416 >        case 'a':                       // ASCII input
417                  if (!orig_dir)
418                          return skipWords(6*n2go);
419                  while (n2go-- > 0) {
# Line 410 | Line 426 | getRayBundle(FVECT *orig_dir = NULL)
426                          orig_dir += 2;
427                  }
428                  break;
429 <        case 'f':                               // float input
429 >        case 'f':                       // float input
430                  if (!orig_dir)
431                          return skipBytes(6*sizeof(float)*n2go);
432   #ifdef SMLFLT
433                  if (getbinary(orig_dir, sizeof(FVECT), 2*n2go, stdin) != 2*n2go)
434                          return false;
435 +                orig_dir += 2*n2go;
436   #else
437                  while (n2go-- > 0) {
438                          float   fvecs[6];
# Line 427 | Line 444 | getRayBundle(FVECT *orig_dir = NULL)
444                  }
445   #endif
446                  break;
447 <        case 'd':                               // double input
447 >        case 'd':                       // double input
448                  if (!orig_dir)
449                          return skipBytes(6*sizeof(double)*n2go);
450   #ifndef SMLFLT
451                  if (getbinary(orig_dir, sizeof(FVECT), 2*n2go, stdin) != 2*n2go)
452                          return false;
453 +                orig_dir += 2*n2go;
454   #else
455                  while (n2go-- > 0) {
456                          double  dvecs[6];
# Line 448 | Line 466 | getRayBundle(FVECT *orig_dir = NULL)
466                  error(INTERNAL, "unsupported format in getRayBundle()");
467                  return false;
468          }
469 <        int     warned = 0;             // normalize directions
452 <        n2go = myRCmanager.accum;
469 >        n2go = myRCmanager.accum;       // normalize directions
470          while (n2go-- > 0) {
471                  orig_dir -= 2;
472 <                if (normalize(orig_dir[1]) == 0)
456 <                        if (!warned++)
457 <                                error(WARNING, "zero ray direction on input");
472 >                normalize(orig_dir[1]);
473          }
474          return true;
475   }
# Line 482 | Line 497 | rxcontrib(const int rstart)
497                  }
498                  last_report = tstart = time(0);
499          }
500 +                                        // start children as requested
501 +        myRCmanager.SetThreadCount(nproc);
502 +
503          while (r < totRows) {           // loop until done
504                  time_t  tnow;
505                  if (!getRayBundle(odarr))
# Line 491 | Line 509 | rxcontrib(const int rstart)
509                  r++;
510                  if (report_intvl <= 0)
511                          continue;
512 <                tnow = time(0);         // time to report progress?
513 <                if (r == totRows)
514 <                        myRCmanager.FlushQueue();
515 <                else if (tnow < last_report+report_intvl)
512 >                if (r == totRows)       // need to finish up?
513 >                        myRCmanager.SetThreadCount(1);
514 >                tnow = time(0);
515 >                if ((r < totRows) & (tnow < last_report+report_intvl))
516                          continue;
517                  sprintf(errmsg, "%.2f%% done after %.3f hours\n",
518                                  100.*myRCmanager.GetRowFinished()/totRows,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines