--- ray/src/rt/rtmain.c 2009/12/12 19:01:00 2.18 +++ ray/src/rt/rtmain.c 2015/04/23 20:29:14 2.25 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rtmain.c,v 2.18 2009/12/12 19:01:00 greg Exp $"; +static const char RCSid[] = "$Id: rtmain.c,v 2.25 2015/04/23 20:29:14 greg Exp $"; #endif /* * rtmain.c - main for rtrace per-ray calculation program @@ -17,6 +17,7 @@ static const char RCSid[] = "$Id: rtmain.c,v 2.18 2009 #include "ambient.h" #include "random.h" #include "paths.h" +#include "pmapray.h" extern char *progname; /* global argv[0] */ @@ -75,10 +76,11 @@ main(int argc, char *argv[]) case 'n': case 'N': case 'f': case 'F': \ case '-': case '0': var = 0; break; \ default: goto badopt; } + extern char *octname; int persist = 0; char *octnm = NULL; - char **tralp; - int duped1; + char **tralp = NULL; + int duped1 = -1; int rval; int i; /* global program name */ @@ -88,6 +90,7 @@ main(int argc, char *argv[]) ; addobjnotify[i] = tranotify; /* set our defaults */ + rand_samp = 1; maxdepth = -10; minweight = 2e-3; /* option city */ @@ -251,9 +254,7 @@ main(int argc, char *argv[]) if (nproc > 1) { if (persist) error(USER, "multiprocessing incompatible with persist file"); - if (imm_irrad) - error(USER, "multiprocessing incompatible with immediate irradiance"); - if (hresolu > 0 && hresolu < nproc) + if (!vresolu && hresolu > 0 && hresolu < nproc) error(WARNING, "number of cores should not exceed horizontal resolution"); if (trace != NULL) error(WARNING, "multiprocessing does not work properly with trace mode"); @@ -315,7 +316,7 @@ main(int argc, char *argv[]) #endif if (outform != 'a') SET_FILE_BINARY(stdout); - readoct(octnm, loadflags, &thescene, NULL); + readoct(octname = octnm, loadflags, &thescene, NULL); nsceneobjs = nobjects; if (loadflags & IO_INFO) { /* print header */ @@ -325,11 +326,13 @@ main(int argc, char *argv[]) fputformat(formstr(outform), stdout); putchar('\n'); } - + + ray_init_pmap(); /* PMAP: set up & load photon maps */ + marksources(); /* find and mark sources */ setambient(); /* initialize ambient calculation */ - + #ifdef PERSIST if (persist) { fflush(stdout); @@ -354,10 +357,8 @@ runagain: if (persist) dupheader(); /* send header to stdout */ #endif - if (nproc > 1) /* start multiprocessing */ - ray_popen(nproc); /* trace rays */ - rtrace(NULL); + rtrace(NULL, nproc); /* flush ambient file */ ambsync(); #ifdef PERSIST @@ -377,6 +378,9 @@ runagain: goto runagain; } #endif + + ray_done_pmap(); /* PMAP: free photon maps */ + quit(0); badopt: @@ -462,7 +466,8 @@ printdefaults(void) /* print default values to stdou if (imm_irrad) printf("-I+\t\t\t\t# immediate irradiance on\n"); printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc); - printf("-x %-9d\t\t\t# x resolution (flush interval)\n", hresolu); + printf("-x %-9d\t\t\t# %s\n", hresolu, + vresolu && hresolu ? "x resolution" : "flush interval"); printf("-y %-9d\t\t\t# y resolution\n", vresolu); printf(lim_dist ? "-ld+\t\t\t\t# limit distance on\n" : "-ld-\t\t\t\t# limit distance off\n");