--- ray/src/rt/rpmain.c 2003/07/03 18:03:58 2.5 +++ ray/src/rt/rpmain.c 2013/08/07 05:10:09 2.15 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rpmain.c,v 2.5 2003/07/03 18:03:58 greg Exp $"; +static const char RCSid[] = "$Id: rpmain.c,v 2.15 2013/08/07 05:10:09 greg Exp $"; #endif /* * rpmain.c - main for rpict batch rendering program @@ -7,13 +7,11 @@ static const char RCSid[] = "$Id: rpmain.c,v 2.5 2003/ #include "copyright.h" -#include +#include #include -#ifdef _WIN32 - #include /* getpid */ -#endif #include "platform.h" +#include "rtprocess.h" /* getpid() */ #include "ray.h" #include "source.h" #include "ambient.h" @@ -29,13 +27,9 @@ static const char RCSid[] = "$Id: rpmain.c,v 2.5 2003/ #endif char *progname; /* argv[0] */ - char *octname; /* octree name */ - char *sigerr[NSIG]; /* signal error messages */ - char *shm_boundary = NULL; /* boundary of shared memory */ - char *errfile = NULL; /* error output file */ extern time_t time(); @@ -55,15 +49,15 @@ extern double dstrpix; /* square pixel distribution extern double mblur; /* motion blur parameter */ -void onsig(); -void sigdie(); -void printdefaults(); +extern double dblur; /* depth-of-field blur parameter */ +static void onsig(int signo); +static void sigdie(int signo, char *msg); +static void printdefaults(void); + int -main(argc, argv) -int argc; -char *argv[]; +main(int argc, char *argv[]) { #define check(ol,al) if (argv[i][ol] || \ badarg(argc-i-1,argv+i+1,al)) \ @@ -82,7 +76,7 @@ char *argv[]; int loadflags = ~IO_FILES; int seqstart = 0; int persist = 0; - int duped1; + int duped1 = -1; int rval; int i; /* record start time */ @@ -160,6 +154,10 @@ char *argv[]; check(3,"f"); mblur = atof(argv[++i]); break; + case 'd': /* aperture */ + check(3,"f"); + dblur = atof(argv[++i]); + break; default: goto badopt; } @@ -228,7 +226,13 @@ char *argv[]; /* initialize object types */ initotypes(); /* initialize urand */ - initurand(2048); + if (rand_samp) { + srandom((long)time(0)); + initurand(0); + } else { + srandom(0L); + initurand(2048); + } /* set up signal handling */ sigdie(SIGINT, "Interrupt"); #ifdef SIGHUP @@ -313,18 +317,20 @@ char *argv[]; pflock(1); pfhold(); tstart = time((time_t *)NULL); + ambsync(); /* load new values */ } if (rval < 0) error(SYSTEM, "cannot fork child for persist function"); - pfdetach(); /* parent exits */ + pfdetach(); /* parent will run then exit */ } } runagain: - if (persist) + if (persist) { if (outfile == NULL) /* if out to stdout */ dupheader(); /* send header */ else /* if out to file */ duped1 = dup(fileno(stdout)); /* hang onto pipe */ + } #endif /* batch render picture(s) */ rpict(seqstart, outfile, zfile, recover); @@ -355,6 +361,7 @@ runagain: badopt: sprintf(errmsg, "command line error at '%s'", argv[i]); error(USER, errmsg); + return 1; /* pro forma return */ #undef check #undef bool @@ -362,8 +369,9 @@ badopt: void -wputs(s) /* warning output function */ -char *s; +wputs( /* warning output function */ + char *s +) { int lasterrno = errno; eputs(s); @@ -372,8 +380,9 @@ char *s; void -eputs(s) /* put string to stderr */ -register char *s; +eputs( /* put string to stderr */ + register char *s +) { static int midline = 0; @@ -391,9 +400,10 @@ register char *s; } -void -onsig(signo) /* fatal signal */ -int signo; +static void +onsig( /* fatal signal */ + int signo +) { static int gotsig = 0; @@ -411,10 +421,11 @@ int signo; } -void -sigdie(signo, msg) /* set fatal signal */ -int signo; -char *msg; +static void +sigdie( /* set fatal signal */ + int signo, + char *msg +) { if (signal(signo, onsig) == SIG_IGN) signal(signo, SIG_IGN); @@ -422,17 +433,16 @@ char *msg; } -void -printdefaults() /* print default values to stdout */ +static void +printdefaults(void) /* print default values to stdout */ { - register char *cp; - printf("-vt%c\t\t\t\t# view type %s\n", ourview.type, ourview.type==VT_PER ? "perspective" : ourview.type==VT_PAR ? "parallel" : ourview.type==VT_HEM ? "hemispherical" : ourview.type==VT_ANG ? "angular" : ourview.type==VT_CYL ? "cylindrical" : + ourview.type==VT_PLS ? "planisphere" : "unknown"); printf("-vp %f %f %f\t# view point\n", ourview.vp[0], ourview.vp[1], ourview.vp[2]); @@ -451,6 +461,7 @@ printdefaults() /* print default values to stdout */ printf("-pa %f\t\t\t# pixel aspect ratio\n", pixaspect); printf("-pj %f\t\t\t# pixel jitter\n", dstrpix); printf("-pm %f\t\t\t# pixel motion\n", mblur); + printf("-pd %f\t\t\t# pixel depth-of-field\n", dblur); printf("-ps %-9d\t\t\t# pixel sample\n", psample); printf("-pt %f\t\t\t# pixel threshold\n", maxdiff); printf("-t %-9d\t\t\t# time between reports\n", ralrm);