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 |
|
|
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? |
60 |
> |
// Exit program |
61 |
|
void |
62 |
|
quit(int code) /* quit program */ |
63 |
|
{ |
64 |
< |
ambsync(); // flush ambient cache |
65 |
< |
|
66 |
< |
ray_done_pmap(); /* PMAP: free photon maps */ |
67 |
< |
|
68 |
< |
exit(code); |
64 |
> |
if (nproc < 0) { |
65 |
> |
ray_pnprocs = -1; // hack to avoid cleanup in child |
66 |
> |
_exit(code); |
67 |
> |
} |
68 |
> |
exit(code); // parent still frees everything (*yawn*) |
69 |
|
} |
70 |
|
|
71 |
|
|
322 |
|
// render tiles |
323 |
|
dtype = rpiece(outfile, dtype, zfile); |
324 |
|
|
325 |
+ |
ambsync(); // flush ambient cache |
326 |
+ |
|
327 |
+ |
ray_done_pmap(); /* PMAP: free photon maps */ |
328 |
+ |
|
329 |
|
quit(dtype==RDTnone); // status is 1 on failure |
330 |
|
|
331 |
|
badopt: |
512 |
|
|
513 |
|
if (cpid == 0) { // children render tiles |
514 |
|
sleep(nproc - cnt); // avoid race conditions |
515 |
+ |
nproc = -1; // flag as child |
516 |
|
return false; |
517 |
|
} |
518 |
|
cow_doneshare(); // parent frees memory and waits |
618 |
|
} else { |
619 |
|
dt = myRPmanager.ReopenOutput(pdfp, pout, zout); |
620 |
|
if (dt == RDTnone) |
621 |
< |
quit(1); |
621 |
> |
return RDTnone; |
622 |
|
if (!fscnresolu(&hresolu, &vresolu, pdfp[0])) |
623 |
|
error(USER, "missing picture resolution"); |
624 |
|
pixaspect = .0; // need to leave this as is |
648 |
|
myRPmanager.AddHeader(buf); |
649 |
|
dt = myRPmanager.NewOutput(pdfp, pout, dt, zout); |
650 |
|
if (dt == RDTnone) |
651 |
< |
quit(1); |
651 |
> |
return RDTnone; |
652 |
|
fprtresolu(hresolu, vresolu, pdfp[0]); |
653 |
|
fflush(pdfp[0]); |
654 |
|
if (RDTdepthT(dt) == RDTdshort) { |