37 |
|
|
38 |
|
double dblur = 0.; /* depth-of-field blur parameter */ |
39 |
|
|
40 |
< |
int nproc = 1; /* number of processes to run */ |
40 |
> |
int nproc = 1; /* number of processes to run (-1 in child) */ |
41 |
|
|
42 |
|
RpictSimulManager myRPmanager; // global simulation manager |
43 |
|
|
56 |
|
"AdaptiveShadowTesting\nOutputs=v,l\n" \ |
57 |
|
"OutputCS=RGB,XYZ,prims,spec\n" |
58 |
|
|
59 |
< |
|
60 |
< |
// We could call myRPmanager.Cleanup() but why waste time |
61 |
< |
// unwinding data structures when the whole frame is going away? |
59 |
> |
// Exit program |
60 |
|
void |
61 |
|
quit(int code) /* quit program */ |
62 |
|
{ |
63 |
< |
ambsync(); // flush ambient cache |
63 |
> |
if (nproc < 0) { |
64 |
> |
ray_pnprocs = -1; // hack to avoid cleanup in child |
65 |
> |
_exit(code); |
66 |
> |
} |
67 |
> |
exit(code); // parent still frees everything (*yawn*) |
68 |
> |
} |
69 |
|
|
70 |
< |
ray_done_pmap(); /* PMAP: free photon maps */ |
71 |
< |
|
72 |
< |
exit(code); |
70 |
> |
/* Set default options */ |
71 |
> |
static void |
72 |
> |
default_options(void) |
73 |
> |
{ |
74 |
> |
shadthresh = .05; |
75 |
> |
shadcert = .5; |
76 |
> |
srcsizerat = .25; |
77 |
> |
directrelay = 1; |
78 |
> |
ambacc = 0.2; |
79 |
> |
ambres = 64; |
80 |
> |
ambdiv = 512; |
81 |
> |
ambssamp = 128; |
82 |
> |
maxdepth = 7; |
83 |
|
} |
84 |
|
|
72 |
– |
|
85 |
|
int |
86 |
|
main(int argc, char *argv[]) |
87 |
|
{ |
108 |
|
strcat(RFeatureList, RXPIECE_FEATURES); |
109 |
|
if (argc > 1 && !strcmp(argv[1], "-features")) |
110 |
|
return feature_status(argc-2, argv+2); |
111 |
+ |
/* set defaults */ |
112 |
+ |
default_options(); |
113 |
|
/* option city */ |
114 |
|
for (i = 1; i < argc; i++) { |
115 |
|
/* expand arguments */ |
337 |
|
// render tiles |
338 |
|
dtype = rpiece(outfile, dtype, zfile); |
339 |
|
|
340 |
+ |
ambsync(); // flush ambient cache |
341 |
+ |
|
342 |
+ |
ray_done_pmap(); /* PMAP: free photon maps */ |
343 |
+ |
|
344 |
|
quit(dtype==RDTnone); // status is 1 on failure |
345 |
|
|
346 |
|
badopt: |
358 |
|
const char *s |
359 |
|
) |
360 |
|
{ |
361 |
+ |
if (!erract[WARNING].pf) |
362 |
+ |
return; // warnings were disabled! |
363 |
|
int lasterrno = errno; |
364 |
|
eputs(s); |
365 |
|
errno = lasterrno; |
527 |
|
|
528 |
|
if (cpid == 0) { // children render tiles |
529 |
|
sleep(nproc - cnt); // avoid race conditions |
530 |
+ |
nproc = -1; // flag as child |
531 |
|
return false; |
532 |
|
} |
533 |
|
cow_doneshare(); // parent frees memory and waits |
633 |
|
} else { |
634 |
|
dt = myRPmanager.ReopenOutput(pdfp, pout, zout); |
635 |
|
if (dt == RDTnone) |
636 |
< |
quit(1); |
636 |
> |
return RDTnone; |
637 |
|
if (!fscnresolu(&hresolu, &vresolu, pdfp[0])) |
638 |
|
error(USER, "missing picture resolution"); |
639 |
|
pixaspect = .0; // need to leave this as is |
663 |
|
myRPmanager.AddHeader(buf); |
664 |
|
dt = myRPmanager.NewOutput(pdfp, pout, dt, zout); |
665 |
|
if (dt == RDTnone) |
666 |
< |
quit(1); |
666 |
> |
return RDTnone; |
667 |
|
fprtresolu(hresolu, vresolu, pdfp[0]); |
668 |
|
fflush(pdfp[0]); |
669 |
|
if (RDTdepthT(dt) == RDTdshort) { |