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

Comparing ray/src/rt/rpmain.c (file contents):
Revision 2.9 by greg, Tue Jan 18 00:33:16 2005 UTC vs.
Revision 2.21 by greg, Wed Oct 19 21:25:20 2022 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7  
8   #include "copyright.h"
9  
10 < #include  <sys/types.h>
10 > #include  <time.h>
11   #include  <signal.h>
12  
13   #include  "platform.h"
# Line 18 | Line 18 | static const char      RCSid[] = "$Id$";
18   #include  "random.h"
19   #include  "paths.h"
20   #include  "view.h"
21 + #include  "pmapray.h"
22  
23                                          /* persistent processes define */
24   #ifdef  F_SETLKW
# Line 54 | Line 55 | extern double  dblur;                  /* depth-of-field blur paramet
55   static void onsig(int signo);
56   static void sigdie(int  signo, char  *msg);
57   static void printdefaults(void);
58 +                                        /* rpict additional features */
59 + #ifdef PERSIST
60 + #define RPICT_FEATURES  "Persist\nParallelPersist\n" \
61 +                        "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \
62 +                        "HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \
63 +                        "PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \
64 +                        "SmallSourceDrawing\nViewSequence\nProgressReporting\n"
65 + #else
66 + #define RPICT_FEATURES  "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \
67 +                        "HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \
68 +                        "PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \
69 +                        "SmallSourceDrawing\nViewSequence\nProgressReporting\n"
70 + #endif
71  
72  
73   int
# Line 62 | Line 76 | main(int  argc, char  *argv[])
76   #define  check(ol,al)           if (argv[i][ol] || \
77                                  badarg(argc-i-1,argv+i+1,al)) \
78                                  goto badopt
79 < #define  bool(olen,var)         switch (argv[i][olen]) { \
79 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
80                                  case '\0': var = !var; break; \
81                                  case 'y': case 'Y': case 't': case 'T': \
82                                  case '+': case '1': var = 1; break; \
# Line 76 | Line 90 | main(int  argc, char  *argv[])
90          int  loadflags = ~IO_FILES;
91          int  seqstart = 0;
92          int  persist = 0;
93 <        int  duped1;
93 >        int  duped1 = -1;
94          int  rval;
95          int  i;
96                                          /* record start time */
97          tstart = time((time_t *)NULL);
98                                          /* global program name */
99          progname = argv[0] = fixargv0(argv[0]);
100 +                                        /* feature check only? */
101 +        strcat(RFeatureList, RPICT_FEATURES);
102 +        if (!strcmp(argv[1], "-features"))
103 +                return feature_status(argc-2, argv+2);
104                                          /* option city */
105          for (i = 1; i < argc; i++) {
106                                                  /* expand arguments */
# Line 208 | Line 226 | main(int  argc, char  *argv[])
226   #endif
227                  case 'w':                               /* warnings */
228                          rval = erract[WARNING].pf != NULL;
229 <                        bool(2,rval);
229 >                        check_bool(2,rval);
230                          if (rval) erract[WARNING].pf = wputs;
231                          else erract[WARNING].pf = NULL;
232                          break;
# Line 226 | Line 244 | main(int  argc, char  *argv[])
244                                          /* initialize object types */
245          initotypes();
246                                          /* initialize urand */
247 <        initurand(2048);
247 >        if (rand_samp) {
248 >                srandom((long)time(0));
249 >                initurand(0);
250 >        } else {
251 >                srandom(0L);
252 >                initurand(2048);
253 >        }
254                                          /* set up signal handling */
255          sigdie(SIGINT, "Interrupt");
256   #ifdef SIGHUP
# Line 279 | Line 303 | main(int  argc, char  *argv[])
303   #endif
304          if (outfile != NULL)
305                  openheader();
282 #ifdef  _WIN32
306          SET_FILE_BINARY(stdout);
307          if (octname == NULL)
308                  SET_FILE_BINARY(stdin);
286 #endif
309          readoct(octname, loadflags, &thescene, NULL);
310          nsceneobjs = nobjects;
311  
# Line 291 | Line 313 | main(int  argc, char  *argv[])
313                  printargs(i, argv, stdout);
314                  printf("SOFTWARE= %s\n", VersionID);
315          }
316 +                  
317 +        ray_init_pmap();     /* PMAP: set up & load photon maps */
318  
319          marksources();                  /* find and mark sources */
320  
321          setambient();                   /* initialize ambient calculation */
322 +        
323 +        fflush(stdout);                 /* in case we're duplicating header */
324  
325   #ifdef  PERSIST
326          if (persist) {
301                fflush(stdout);
327                  if (outfile == NULL) {          /* reconnect stdout */
328                          dup2(duped1, fileno(stdout));
329                          close(duped1);
# Line 311 | Line 336 | main(int  argc, char  *argv[])
336                                  pflock(1);
337                                  pfhold();
338                                  tstart = time((time_t *)NULL);
339 +                                ambsync();              /* load new values */
340                          }
341                          if (rval < 0)
342                                  error(SYSTEM, "cannot fork child for persist function");
343 <                        pfdetach();             /* parent exits */
343 >                        pfdetach();             /* parent will run then exit */
344                  }
345          }
346   runagain:
# Line 349 | Line 375 | runagain:
375                  goto runagain;
376          }
377   #endif
378 +
379 +
380 +        ray_done_pmap();           /* PMAP: free photon maps */
381 +        
382          quit(0);
383  
384   badopt:
# Line 357 | Line 387 | badopt:
387          return 1; /* pro forma return */
388  
389   #undef  check
390 < #undef  bool
390 > #undef  check_bool
391   }
392  
393  
# Line 374 | Line 404 | wputs(                         /* warning output function */
404  
405   void
406   eputs(                          /* put string to stderr */
407 <        register char  *s
407 >        char  *s
408   )
409   {
410          static int  midline = 0;
# Line 435 | Line 465 | printdefaults(void)                    /* print default values to stdou
465                          ourview.type==VT_HEM ? "hemispherical" :
466                          ourview.type==VT_ANG ? "angular" :
467                          ourview.type==VT_CYL ? "cylindrical" :
468 +                        ourview.type==VT_PLS ? "planisphere" :
469                          "unknown");
470          printf("-vp %f %f %f\t# view point\n",
471                          ourview.vp[0], ourview.vp[1], ourview.vp[2]);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines