--- ray/src/rt/rtmain.c 2023/12/11 17:21:59 2.49 +++ ray/src/rt/rtmain.c 2025/06/20 03:43:17 2.60 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rtmain.c,v 2.49 2023/12/11 17:21:59 greg Exp $"; +static const char RCSid[] = "$Id: rtmain.c,v 2.60 2025/06/20 03:43:17 greg Exp $"; #endif /* * rtmain.c - main for rtrace per-ray calculation program @@ -13,16 +13,14 @@ static const char RCSid[] = "$Id: rtmain.c,v 2.49 2023 #include "rtprocess.h" /* getpid() */ #include "resolu.h" #include "ray.h" +#include "func.h" #include "source.h" #include "ambient.h" #include "random.h" -#include "paths.h" #include "pmapray.h" extern char *progname; /* global argv[0] */ -extern char *shm_boundary; /* boundary of shared memory */ - /* persistent processes define */ #ifdef F_SETLKW #define PERSIST 1 /* normal persist */ @@ -59,7 +57,7 @@ extern void tranotify(OBJECT obj); char *tralist[MAXMODLIST]; /* list of modifers to trace (or no) */ int traincl = -1; /* include == 1, exclude == 0 */ -double (*sens_curve)(SCOLOR scol) = NULL; /* spectral conversion for 1-channel */ +double (*sens_curve)(const SCOLOR scol) = NULL; /* spectral conversion for 1-channel */ double out_scalefactor = 1; /* output calibration scale factor */ RGBPRIMP out_prims = stdprims; /* output color primitives (NULL if spectral) */ static RGBPRIMS our_prims; /* private output color primitives */ @@ -77,14 +75,16 @@ static void printdefaults(void); "HessianAmbientCache\nAmbientAveraging\n" \ "AmbientValueSharing\nAdaptiveShadowTesting\n" \ "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \ - "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" + "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" \ + "OutputCS=RGB,XYZ,Y,S,M,prims,spec\n" #else #define RTRACE_FEATURES "IrradianceCalc\nIrradianceCalc\nDistanceLimiting\n" \ "ParticipatingMedia=Mist\n" \ "HessianAmbientCache\nAmbientAveraging\n" \ "AmbientValueSharing\nAdaptiveShadowTesting\n" \ "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \ - "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" + "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" \ + "OutputCS=RGB,XYZ,Y,S,M,prims,spec\n" #endif @@ -114,6 +114,8 @@ main(int argc, char *argv[]) strcat(RFeatureList, RTRACE_FEATURES); if (argc > 1 && !strcmp(argv[1], "-features")) return feature_status(argc-2, argv+2); + /* initialize calcomp routines */ + initfunc(); /* add trace notify function */ for (i = 0; addobjnotify[i] != NULL; i++) ; @@ -294,14 +296,20 @@ main(int argc, char *argv[]) sens_curve = NULL; } break; case 'Y': /* photopic response */ + if (argv[i][3]) + goto badopt; sens_curve = scolor_photopic; out_scalefactor = WHTEFFICACY; break; case 'S': /* scotopic response */ + if (argv[i][3]) + goto badopt; sens_curve = scolor_scotopic; out_scalefactor = WHTSCOTOPIC; break; case 'M': /* melanopic response */ + if (argv[i][3]) + goto badopt; sens_curve = scolor_melanopic; out_scalefactor = WHTMELANOPIC; break; @@ -342,7 +350,9 @@ main(int argc, char *argv[]) rval = setspectrsamp(CNDX, WLPART); if (rval < 0) error(USER, "unsupported spectral sampling"); - if (out_prims != NULL) { + if (sens_curve != NULL) + out_prims = NULL; + else if (out_prims != NULL) { if (!rval) error(WARNING, "spectral range incompatible with color output"); } else if (NCSAMP == 3) @@ -352,13 +362,7 @@ main(int argc, char *argv[]) /* initialize object types */ initotypes(); /* initialize urand */ - if (rand_samp) { - srandom((long)time(0)); - initurand(0); - } else { - srandom(0L); - initurand(2048); - } + reset_random(); /* set up signal handling */ sigdie(SIGINT, "Interrupt"); #ifdef SIGHUP @@ -445,9 +449,7 @@ main(int argc, char *argv[]) dup2(duped1, fileno(stdout)); close(duped1); if (persist == PARALLEL) { /* multiprocessing */ - preload_objs(); /* preload scene */ - shm_boundary = (char *)malloc(16); - strcpy(shm_boundary, "SHM_BOUNDARY"); + cow_memshare(); /* preloads scene */ while ((rval=fork()) == 0) { /* keep on forkin' */ pflock(1); pfhold(); @@ -504,6 +506,8 @@ wputs( /* warning output function */ ) { int lasterrno = errno; + if (erract[WARNING].pf == NULL) + return; /* called by calcomp or someone */ eputs(s); errno = lasterrno; } @@ -624,7 +628,7 @@ printdefaults(void) /* print default values to stdou out_prims[GRN][0], out_prims[GRN][1], out_prims[BLU][0], out_prims[BLU][1], out_prims[WHT][0], out_prims[WHT][1]); - if (NCSAMP > 3) + if ((sens_curve == NULL) & (NCSAMP > 3)) printf(out_prims != NULL ? "-co-\t\t\t\t# output tristimulus colors\n" : "-co+\t\t\t\t# output spectral values\n"); print_rdefaults();