7 |
|
|
8 |
|
#include "copyright.h" |
9 |
|
|
10 |
< |
#include <sys/types.h> |
10 |
> |
#include <time.h> |
11 |
|
#include <signal.h> |
12 |
|
|
13 |
|
#include "platform.h" |
18 |
|
#include "random.h" |
19 |
|
#include "paths.h" |
20 |
|
#include "view.h" |
21 |
+ |
#include "pmapray.h" |
22 |
|
|
23 |
|
/* persistent processes define */ |
24 |
|
#ifdef F_SETLKW |
50 |
|
|
51 |
|
extern double mblur; /* motion blur parameter */ |
52 |
|
|
53 |
+ |
extern double dblur; /* depth-of-field blur parameter */ |
54 |
+ |
|
55 |
|
static void onsig(int signo); |
56 |
|
static void sigdie(int signo, char *msg); |
57 |
|
static void printdefaults(void); |
58 |
+ |
/* rpict additional features */ |
59 |
+ |
#ifdef PERSIST |
60 |
+ |
#define RPICT_FEATURES "Persist\nParallelPersist\n" \ |
61 |
+ |
"ParticipatingMedia=Mist\n" \ |
62 |
+ |
"Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \ |
63 |
+ |
"HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \ |
64 |
+ |
"PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \ |
65 |
+ |
"SmallSourceDrawing\nViewSequence\nProgressReporting\n" \ |
66 |
+ |
"AdaptiveShadowTesting\nOutputs=v,l\n" |
67 |
+ |
#else |
68 |
+ |
#define RPICT_FEATURES "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \ |
69 |
+ |
"ParticipatingMedia=Mist\n" \ |
70 |
+ |
"HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \ |
71 |
+ |
"PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \ |
72 |
+ |
"SmallSourceDrawing\nViewSequence\nProgressReporting\n" \ |
73 |
+ |
"AdaptiveShadowTesting\nOutputs=v,l\n" |
74 |
+ |
#endif |
75 |
|
|
76 |
|
|
77 |
|
int |
80 |
|
#define check(ol,al) if (argv[i][ol] || \ |
81 |
|
badarg(argc-i-1,argv+i+1,al)) \ |
82 |
|
goto badopt |
83 |
< |
#define bool(olen,var) switch (argv[i][olen]) { \ |
83 |
> |
#define check_bool(olen,var) switch (argv[i][olen]) { \ |
84 |
|
case '\0': var = !var; break; \ |
85 |
|
case 'y': case 'Y': case 't': case 'T': \ |
86 |
|
case '+': case '1': var = 1; break; \ |
94 |
|
int loadflags = ~IO_FILES; |
95 |
|
int seqstart = 0; |
96 |
|
int persist = 0; |
97 |
< |
int duped1; |
97 |
> |
int duped1 = -1; |
98 |
|
int rval; |
99 |
|
int i; |
100 |
|
/* record start time */ |
101 |
|
tstart = time((time_t *)NULL); |
102 |
|
/* global program name */ |
103 |
|
progname = argv[0] = fixargv0(argv[0]); |
104 |
+ |
/* feature check only? */ |
105 |
+ |
strcat(RFeatureList, RPICT_FEATURES); |
106 |
+ |
if (argc > 1 && !strcmp(argv[1], "-features")) |
107 |
+ |
return feature_status(argc-2, argv+2); |
108 |
|
/* option city */ |
109 |
|
for (i = 1; i < argc; i++) { |
110 |
|
/* expand arguments */ |
176 |
|
check(3,"f"); |
177 |
|
mblur = atof(argv[++i]); |
178 |
|
break; |
179 |
+ |
case 'd': /* aperture */ |
180 |
+ |
check(3,"f"); |
181 |
+ |
dblur = atof(argv[++i]); |
182 |
+ |
break; |
183 |
|
default: |
184 |
|
goto badopt; |
185 |
|
} |
230 |
|
#endif |
231 |
|
case 'w': /* warnings */ |
232 |
|
rval = erract[WARNING].pf != NULL; |
233 |
< |
bool(2,rval); |
233 |
> |
check_bool(2,rval); |
234 |
|
if (rval) erract[WARNING].pf = wputs; |
235 |
|
else erract[WARNING].pf = NULL; |
236 |
|
break; |
248 |
|
/* initialize object types */ |
249 |
|
initotypes(); |
250 |
|
/* initialize urand */ |
251 |
< |
initurand(2048); |
251 |
> |
if (rand_samp) { |
252 |
> |
srandom((long)time(0)); |
253 |
> |
initurand(0); |
254 |
> |
} else { |
255 |
> |
srandom(0L); |
256 |
> |
initurand(2048); |
257 |
> |
} |
258 |
|
/* set up signal handling */ |
259 |
|
sigdie(SIGINT, "Interrupt"); |
260 |
|
#ifdef SIGHUP |
307 |
|
#endif |
308 |
|
if (outfile != NULL) |
309 |
|
openheader(); |
276 |
– |
#ifdef _WIN32 |
310 |
|
SET_FILE_BINARY(stdout); |
311 |
|
if (octname == NULL) |
312 |
|
SET_FILE_BINARY(stdin); |
280 |
– |
#endif |
313 |
|
readoct(octname, loadflags, &thescene, NULL); |
314 |
|
nsceneobjs = nobjects; |
315 |
|
|
317 |
|
printargs(i, argv, stdout); |
318 |
|
printf("SOFTWARE= %s\n", VersionID); |
319 |
|
} |
320 |
+ |
|
321 |
+ |
ray_init_pmap(); /* PMAP: set up & load photon maps */ |
322 |
|
|
323 |
|
marksources(); /* find and mark sources */ |
324 |
|
|
325 |
|
setambient(); /* initialize ambient calculation */ |
326 |
+ |
|
327 |
+ |
fflush(stdout); /* in case we're duplicating header */ |
328 |
|
|
329 |
|
#ifdef PERSIST |
330 |
|
if (persist) { |
295 |
– |
fflush(stdout); |
331 |
|
if (outfile == NULL) { /* reconnect stdout */ |
332 |
|
dup2(duped1, fileno(stdout)); |
333 |
|
close(duped1); |
340 |
|
pflock(1); |
341 |
|
pfhold(); |
342 |
|
tstart = time((time_t *)NULL); |
343 |
+ |
ambsync(); /* load new values */ |
344 |
|
} |
345 |
|
if (rval < 0) |
346 |
|
error(SYSTEM, "cannot fork child for persist function"); |
347 |
< |
pfdetach(); /* parent exits */ |
347 |
> |
pfdetach(); /* parent will run then exit */ |
348 |
|
} |
349 |
|
} |
350 |
|
runagain: |
379 |
|
goto runagain; |
380 |
|
} |
381 |
|
#endif |
382 |
+ |
|
383 |
+ |
|
384 |
+ |
ray_done_pmap(); /* PMAP: free photon maps */ |
385 |
+ |
|
386 |
|
quit(0); |
387 |
|
|
388 |
|
badopt: |
391 |
|
return 1; /* pro forma return */ |
392 |
|
|
393 |
|
#undef check |
394 |
< |
#undef bool |
394 |
> |
#undef check_bool |
395 |
|
} |
396 |
|
|
397 |
|
|
398 |
|
void |
399 |
|
wputs( /* warning output function */ |
400 |
< |
char *s |
400 |
> |
const char *s |
401 |
|
) |
402 |
|
{ |
403 |
|
int lasterrno = errno; |
408 |
|
|
409 |
|
void |
410 |
|
eputs( /* put string to stderr */ |
411 |
< |
register char *s |
411 |
> |
const char *s |
412 |
|
) |
413 |
|
{ |
414 |
|
static int midline = 0; |
469 |
|
ourview.type==VT_HEM ? "hemispherical" : |
470 |
|
ourview.type==VT_ANG ? "angular" : |
471 |
|
ourview.type==VT_CYL ? "cylindrical" : |
472 |
+ |
ourview.type==VT_PLS ? "planisphere" : |
473 |
|
"unknown"); |
474 |
|
printf("-vp %f %f %f\t# view point\n", |
475 |
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |
488 |
|
printf("-pa %f\t\t\t# pixel aspect ratio\n", pixaspect); |
489 |
|
printf("-pj %f\t\t\t# pixel jitter\n", dstrpix); |
490 |
|
printf("-pm %f\t\t\t# pixel motion\n", mblur); |
491 |
+ |
printf("-pd %f\t\t\t# pixel depth-of-field\n", dblur); |
492 |
|
printf("-ps %-9d\t\t\t# pixel sample\n", psample); |
493 |
|
printf("-pt %f\t\t\t# pixel threshold\n", maxdiff); |
494 |
|
printf("-t %-9d\t\t\t# time between reports\n", ralrm); |