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

Comparing ray/src/rt/rtmain.c (file contents):
Revision 2.47 by greg, Wed Nov 15 18:02:53 2023 UTC vs.
Revision 2.61 by greg, Fri Jun 20 16:34:23 2025 UTC

# Line 13 | Line 13 | static const char      RCSid[] = "$Id$";
13   #include  "rtprocess.h" /* getpid() */
14   #include  "resolu.h"
15   #include  "ray.h"
16 + #include  "func.h"
17   #include  "source.h"
18   #include  "ambient.h"
19   #include  "random.h"
19 #include  "paths.h"
20   #include  "pmapray.h"
21
22 extern char     *progname;              /* global argv[0] */
23
24 extern char     *shm_boundary;          /* boundary of shared memory */
25
21                                          /* persistent processes define */
22   #ifdef  F_SETLKW
23   #define  PERSIST        1               /* normal persist */
# Line 59 | Line 54 | extern void  tranotify(OBJECT obj);
54   char  *tralist[MAXMODLIST];             /* list of modifers to trace (or no) */
55   int  traincl = -1;                      /* include == 1, exclude == 0 */
56  
57 < double  (*sens_curve)(SCOLOR scol) = NULL;      /* spectral conversion for 1-channel */
57 > double  (*sens_curve)(const SCOLOR scol) = NULL;        /* spectral conversion for 1-channel */
58   double  out_scalefactor = 1;            /* output calibration scale factor */
59   RGBPRIMP  out_prims = stdprims;         /* output color primitives (NULL if spectral) */
60   static RGBPRIMS  our_prims;             /* private output color primitives */
# Line 73 | Line 68 | static void printdefaults(void);
68   #ifdef PERSIST
69   #define RTRACE_FEATURES "Persist\nParallelPersist\nMultiprocessing\n" \
70                          "IrradianceCalc\nImmediateIrradiance\nDistanceLimiting\n" \
71 <                        "Hyperspectral\nParticipatingMedia=Mist\n" \
71 >                        "ParticipatingMedia=Mist\n" \
72                          "HessianAmbientCache\nAmbientAveraging\n" \
73                          "AmbientValueSharing\nAdaptiveShadowTesting\n" \
74                          "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \
75 <                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n"
75 >                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" \
76 >                        "OutputCS=RGB,XYZ,Y,S,M,prims,spec\n"
77   #else
78   #define RTRACE_FEATURES "IrradianceCalc\nIrradianceCalc\nDistanceLimiting\n" \
79 <                        "Hyperspectral\nParticipatingMedia=Mist\n" \
79 >                        "ParticipatingMedia=Mist\n" \
80                          "HessianAmbientCache\nAmbientAveraging\n" \
81                          "AmbientValueSharing\nAdaptiveShadowTesting\n" \
82                          "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \
83 <                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n"
83 >                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" \
84 >                        "OutputCS=RGB,XYZ,Y,S,M,prims,spec\n"
85   #endif
86  
87  
# Line 114 | Line 111 | main(int  argc, char  *argv[])
111          strcat(RFeatureList, RTRACE_FEATURES);
112          if (argc > 1 && !strcmp(argv[1], "-features"))
113                  return feature_status(argc-2, argv+2);
114 +                                        /* initialize calcomp routines */
115 +        initfunc();
116                                          /* add trace notify function */
117          for (i = 0; addobjnotify[i] != NULL; i++)
118                  ;
# Line 294 | Line 293 | main(int  argc, char  *argv[])
293                                  sens_curve = NULL;
294                                  } break;
295                          case 'Y':                       /* photopic response */
296 +                                if (argv[i][3])
297 +                                        goto badopt;
298                                  sens_curve = scolor_photopic;
299                                  out_scalefactor = WHTEFFICACY;
300                                  break;
301                          case 'S':                       /* scotopic response */
302 +                                if (argv[i][3])
303 +                                        goto badopt;
304                                  sens_curve = scolor_scotopic;
305                                  out_scalefactor = WHTSCOTOPIC;
306                                  break;
307                          case 'M':                       /* melanopic response */
308 +                                if (argv[i][3])
309 +                                        goto badopt;
310                                  sens_curve = scolor_melanopic;
311                                  out_scalefactor = WHTMELANOPIC;
312                                  break;
# Line 310 | Line 315 | main(int  argc, char  *argv[])
315                          }
316                          break;
317   #if MAXCSAMP>3
318 <                case 'c':                               /* spectral sampling */
319 <                        switch (argv[i][2]) {
315 <                        case 's':                       /* spectral bin count */
316 <                                check(3,"i");
317 <                                NCSAMP = atoi(argv[++i]);
318 <                                break;
319 <                        case 'w':                       /* wavelength extrema */
320 <                                check(3,"ff");
321 <                                WLPART[0] = atof(argv[++i]);
322 <                                WLPART[3] = atof(argv[++i]);
323 <                                break;
324 <                        case 'o':                       /* output spectral results */
325 <                                rval = (out_prims == NULL);
326 <                                check_bool(3,rval);
327 <                                if (rval) out_prims = NULL;
328 <                                else if (out_prims == NULL) out_prims = stdprims;
329 <                                break;
330 <                        default:
318 >                case 'c':                               /* output spectral results */
319 >                        if (argv[i][2] != 'o')
320                                  goto badopt;
321 <                        }
321 >                        rval = (out_prims == NULL) & (sens_curve == NULL);
322 >                        check_bool(3,rval);
323 >                        if (rval) {
324 >                                out_prims = NULL;
325 >                                sens_curve = NULL;
326 >                        } else if (out_prims == NULL)
327 >                                out_prims = stdprims;
328                          break;
329   #endif
330   #ifdef  PERSIST
# Line 352 | Line 347 | main(int  argc, char  *argv[])
347          rval = setspectrsamp(CNDX, WLPART);
348          if (rval < 0)
349                  error(USER, "unsupported spectral sampling");
350 <        if (out_prims != NULL) {
350 >        if (sens_curve != NULL)
351 >                out_prims = NULL;
352 >        else if (out_prims != NULL) {
353                  if (!rval)
354                          error(WARNING, "spectral range incompatible with color output");
355          } else if (NCSAMP == 3)
# Line 362 | Line 359 | main(int  argc, char  *argv[])
359                                          /* initialize object types */
360          initotypes();
361                                          /* initialize urand */
362 <        if (rand_samp) {
366 <                srandom((long)time(0));
367 <                initurand(0);
368 <        } else {
369 <                srandom(0L);
370 <                initurand(2048);
371 <        }
362 >        reset_random();
363                                          /* set up signal handling */
364          sigdie(SIGINT, "Interrupt");
365   #ifdef SIGHUP
# Line 455 | Line 446 | main(int  argc, char  *argv[])
446                  dup2(duped1, fileno(stdout));
447                  close(duped1);
448                  if (persist == PARALLEL) {      /* multiprocessing */
449 <                        preload_objs();         /* preload scene */
459 <                        shm_boundary = (char *)malloc(16);
460 <                        strcpy(shm_boundary, "SHM_BOUNDARY");
449 >                        cow_memshare();         /* preloads scene */
450                          while ((rval=fork()) == 0) {    /* keep on forkin' */
451                                  pflock(1);
452                                  pfhold();
# Line 514 | Line 503 | wputs(                         /* warning output function */
503   )
504   {
505          int  lasterrno = errno;
506 +        if (erract[WARNING].pf == NULL)
507 +                return;         /* called by calcomp or someone */
508          eputs(s);
509          errno = lasterrno;
510   }
# Line 578 | Line 569 | printdefaults(void)                    /* print default values to stdou
569   {
570          char  *cp;
571  
572 +        printf(erract[WARNING].pf != NULL ?
573 +                        "-w+\t\t\t\t# warning messages on\n" :
574 +                        "-w-\t\t\t\t# warning messages off\n");
575          if (imm_irrad)
576                  printf("-I+\t\t\t\t# immediate irradiance on\n");
577          printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc);
# Line 615 | Line 609 | printdefaults(void)                    /* print default values to stdou
609                  case '~': printf(" tilde"); break;
610                  }
611          fputc('\n', stdout);
618        if (NCSAMP > 3) {
619                printf("-cs %-2d\t\t\t\t# number of spectral bins\n", NCSAMP);
620                printf("-cw %3.0f %3.0f\t\t\t# wavelength limits (nm)\n",
621                                WLPART[3], WLPART[0]);
622                printf(out_prims != NULL ? "-co-\t\t\t\t# output tristimulus colors\n" :
623                                "-co+\t\t\t\t# output spectral values\n");
624        }
612          if (sens_curve == scolor_photopic)
613                  printf("-pY\t\t\t\t# photopic output\n");
614          else if (sens_curve == scolor_scotopic)
# Line 638 | Line 625 | printdefaults(void)                    /* print default values to stdou
625                                  out_prims[GRN][0], out_prims[GRN][1],
626                                  out_prims[BLU][0], out_prims[BLU][1],
627                                  out_prims[WHT][0], out_prims[WHT][1]);
628 <        printf(erract[WARNING].pf != NULL ?
629 <                        "-w+\t\t\t\t# warning messages on\n" :
630 <                        "-w-\t\t\t\t# warning messages off\n");
628 >        if ((sens_curve == NULL) & (NCSAMP > 3))
629 >                printf(out_prims != NULL ? "-co-\t\t\t\t# output tristimulus colors\n" :
630 >                                "-co+\t\t\t\t# output spectral values\n");
631          print_rdefaults();
632   }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)