14 |
|
|
15 |
|
#include "platform.h" |
16 |
|
#include "RpictSimulManager.h" |
17 |
+ |
#include "ambient.h" |
18 |
+ |
#include "pmapray.h" |
19 |
|
#include "random.h" |
20 |
|
|
21 |
|
extern char *progname; /* argv[0] */ |
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? |
62 |
|
void |
63 |
|
quit(int code) /* quit program */ |
64 |
|
{ |
65 |
+ |
ambsync(); // flush ambient cache |
66 |
+ |
|
67 |
+ |
ray_done_pmap(); /* PMAP: free photon maps */ |
68 |
+ |
|
69 |
|
exit(code); |
70 |
|
} |
71 |
|
|
323 |
|
// render tiles |
324 |
|
dtype = rpiece(outfile, dtype, zfile); |
325 |
|
|
326 |
< |
quit(dtype==RDTnone); // clean up and exit |
326 |
> |
quit(dtype==RDTnone); // status is 1 on failure |
327 |
|
|
328 |
|
badopt: |
329 |
|
sprintf(errmsg, "command line error at '%s'", argv[i]); |
644 |
|
if (dt == RDTnone) |
645 |
|
quit(1); |
646 |
|
fprtresolu(hresolu, vresolu, pdfp[0]); |
647 |
< |
} |
648 |
< |
if (RDTdepthT(dt) == RDTdshort) { |
641 |
< |
if (newOutput) |
647 |
> |
fflush(pdfp[0]); |
648 |
> |
if (RDTdepthT(dt) == RDTdshort) { |
649 |
|
fprtresolu(hresolu, vresolu, pdfp[1]); |
650 |
< |
else if (!fscnresolu(&hvdim[0], &hvdim[1], pdfp[1]) || |
651 |
< |
(hvdim[0] != hresolu) | (hvdim[1] != vresolu)) |
652 |
< |
error(USER, "mismatched depth file resolution"); |
653 |
< |
} |
650 |
> |
fflush(pdfp[1]); |
651 |
> |
} |
652 |
> |
} else if (RDTdepthT(dt) == RDTdshort && |
653 |
> |
(!fscnresolu(&hvdim[0], &hvdim[1], pdfp[1]) || |
654 |
> |
(hvdim[0] != hresolu) | (hvdim[1] != vresolu))) |
655 |
> |
error(USER, "mismatched depth file resolution"); |
656 |
|
// prepare (flat) pixel buffer |
657 |
|
const long pdata_beg = ftell(pdfp[0]); |
658 |
|
const size_t pixSiz = (RDTcolorT(dt)==RDTrgbe)|(RDTcolorT(dt)==RDTxyze) ? sizeof(COLR) |