--- ray/src/rt/rcmain.c 2016/03/10 18:25:46 2.15 +++ ray/src/rt/rcmain.c 2025/04/22 17:12:25 2.40 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rcmain.c,v 2.15 2016/03/10 18:25:46 schorsch Exp $"; +static const char RCSid[] = "$Id: rcmain.c,v 2.40 2025/04/22 17:12:25 greg Exp $"; #endif /* * rcmain.c - main for rtcontrib ray contribution tracer @@ -43,13 +43,32 @@ int using_stdout = 0; /* are we using stdout? */ int imm_irrad = 0; /* compute immediate irradiance? */ int lim_dist = 0; /* limit distance? */ -const char *modname[MAXMODLIST]; /* ordered modifier name list */ -int nmods = 0; /* number of modifiers */ +int report_intvl = 0; /* reporting interval (seconds) */ +char **modname = NULL; /* ordered modifier name list */ +int nmods = 0; /* number of modifiers */ +int modasiz = 0; /* allocated modifier array size */ + void (*addobjnotify[8])() = {ambnotify, NULL}; -char RCCONTEXT[] = "RC"; /* our special evaluation context */ +char RCCONTEXT[] = "RC."; /* our special evaluation context */ +#if defined(_WIN32) || defined(_WIN64) +#define RCONTRIB_FEATURES "Accumulation\nSummation\nRecovery\n" \ + "ImmediateIrradiance\n" \ + "ProgressReporting\nDistanceLimiting\n" \ + "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \ + "Outputs=V,W\n" \ + "OutputCS=RGB,spec\n" +#else +#define RCONTRIB_FEATURES "Multiprocessing\n" \ + "Accumulation\nSummation\nRecovery\n" \ + "ImmediateIrradiance\n" \ + "ProgressReporting\nDistanceLimiting\n" \ + "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \ + "Outputs=V,W\n" \ + "OutputCS=RGB,spec\n" +#endif static void printdefaults(void) /* print default values to stdout */ @@ -65,10 +84,12 @@ printdefaults(void) /* print default values to stdou printf("-y %-9d\t\t\t# y resolution\n", yres); printf(lim_dist ? "-ld+\t\t\t\t# limit distance on\n" : "-ld-\t\t\t\t# limit distance off\n"); - printf("-h%c\t\t\t\t# %s header\n", header ? '+' : '-', - header ? "output" : "no"); + printf(header ? "-h+\t\t\t\t# output header\n" : + "-h-\t\t\t\t# no header\n"); printf("-f%c%c\t\t\t\t# format input/output = %s/%s\n", inpfmt, outfmt, formstr(inpfmt), formstr(outfmt)); + if (report_intvl > 0) + printf("-t %-9d\t\t\t# time between reports\n", report_intvl); printf(erract[WARNING].pf != NULL ? "-w+\t\t\t\t# warning messages on\n" : "-w-\t\t\t\t# warning messages off\n"); @@ -180,9 +201,17 @@ main(int argc, char *argv[]) progname = argv[0] = fixargv0(argv[0]); gargv = argv; gargc = argc; - /* initialize calcomp routines early */ - initfunc(); - setcontext(RCCONTEXT); + /* feature check only? */ + strcat(RFeatureList, RCONTRIB_FEATURES); + if (argc > 1 && !strcmp(argv[1], "-features")) + return feature_status(argc-2, argv+2); +#if defined(_WIN32) || defined(_WIN64) /* increase file limit to maximum */ + for (i = 8192; i > _IOB_ENTRIES; i >>= 1) + if (_setmaxstdio(i) == i) + break; +#endif + initfunc(); /* initialize calcomp routines */ + calcontext(RCCONTEXT); /* option city */ for (i = 1; i < argc; i++) { /* expand arguments */ @@ -233,10 +262,6 @@ main(int argc, char *argv[]) if (rval) erract[WARNING].pf = wputs; else erract[WARNING].pf = NULL; break; - case 'e': /* expression */ - check(2,"s"); - scompile(argv[++i], NULL, 0); - break; case 'l': /* limit distance */ if (argv[i][2] != 'd') goto badopt; @@ -245,12 +270,7 @@ main(int argc, char *argv[]) case 'I': /* immed. irradiance */ check_bool(2,imm_irrad); break; - case 'f': /* file or force or format */ - if (!argv[i][2]) { - check(2,"s"); - loadfunc(argv[++i]); - break; - } + case 'f': /* force or format */ if (argv[i][2] == 'o') { check_bool(3,force_open); break; @@ -261,10 +281,6 @@ main(int argc, char *argv[]) check(2,"s"); curout = argv[++i]; break; - case 'c': /* input rays per output */ - check(2,"i"); - accumulate = atoi(argv[++i]); - break; case 'r': /* recover output */ check_bool(2,recover); break; @@ -275,6 +291,10 @@ main(int argc, char *argv[]) check(2,"s"); set_eparams(prms = argv[++i]); break; + case 'c': /* sample count */ + check(2,"i"); + accumulate = atoi(argv[++i]); + break; case 'b': /* bin expression/count */ if (argv[i][2] == 'n') { check(3,"s"); @@ -292,6 +312,10 @@ main(int argc, char *argv[]) check(2,"s"); addmodfile(argv[++i], curout, prms, binval, bincnt); break; + case 't': /* reporting interval */ + check(2,"i"); + report_intvl = atoi(argv[++i]); + break; default: goto badopt; } @@ -300,6 +324,9 @@ main(int argc, char *argv[]) error(USER, "missing required modifier argument"); /* override some option settings */ override_options(); + /* set/check spectral sampling */ + if (setspectrsamp(CNDX, WLPART) < 0) + error(USER, "unsupported spectral sampling"); /* initialize object types */ initotypes(); /* initialize urand */ @@ -354,8 +381,6 @@ main(int argc, char *argv[]) rcontrib(); /* trace ray contributions (loop) */ - ambsync(); /* flush ambient file */ - /* PMAP: free photon maps */ ray_done_pmap(); @@ -363,7 +388,7 @@ main(int argc, char *argv[]) badopt: fprintf(stderr, -"Usage: %s [-n nprocs][-V][-r][-e expr][-f source][-o ospec][-p p1=V1,p2=V2][-b binv][-bn N] {-m mod | -M file} [rtrace options] octree\n", +"Usage: %s [-n nprocs][-V][-c count][-r][-e expr][-f source][-o ospec][-p p1=V1,p2=V2][-b binv][-bn N] {-m mod | -M file} [rtrace options] octree\n", progname); sprintf(errmsg, "command line error at '%s'", argv[i]); error(USER, errmsg); @@ -376,10 +401,12 @@ badopt: void wputs( /* warning output function */ - char *s + const char *s ) { int lasterrno = errno; + if (erract[WARNING].pf == NULL) + return; /* called by calcomp or someone */ eputs(s); errno = lasterrno; } @@ -387,7 +414,7 @@ wputs( /* warning output function */ void eputs( /* put string to stderr */ - char *s + const char *s ) { static int midline = 0;