17 |
|
#include "ambient.h" |
18 |
|
#include "random.h" |
19 |
|
#include "paths.h" |
20 |
+ |
#include "pmapray.h" |
21 |
|
|
22 |
|
extern char *progname; /* global argv[0] */ |
23 |
|
|
35 |
|
|
36 |
|
int nproc = 1; /* number of processes */ |
37 |
|
|
38 |
< |
extern char *formstr(); /* string from format */ |
38 |
> |
extern char *formstr(int f); /* string from format */ |
39 |
> |
extern int setrtoutput(void); /* set output values */ |
40 |
|
int inform = 'a'; /* input format */ |
41 |
|
int outform = 'a'; /* output format */ |
42 |
|
char *outvals = "v"; /* output specification */ |
70 |
|
#define check(ol,al) if (argv[i][ol] || \ |
71 |
|
badarg(argc-i-1,argv+i+1,al)) \ |
72 |
|
goto badopt |
73 |
< |
#define bool(olen,var) switch (argv[i][olen]) { \ |
73 |
> |
#define check_bool(olen,var) switch (argv[i][olen]) { \ |
74 |
|
case '\0': var = !var; break; \ |
75 |
|
case 'y': case 'Y': case 't': case 'T': \ |
76 |
|
case '+': case '1': var = 1; break; \ |
77 |
|
case 'n': case 'N': case 'f': case 'F': \ |
78 |
|
case '-': case '0': var = 0; break; \ |
79 |
|
default: goto badopt; } |
80 |
+ |
extern char *octname; |
81 |
|
int persist = 0; |
82 |
|
char *octnm = NULL; |
83 |
< |
char **tralp; |
84 |
< |
int duped1; |
83 |
> |
char **tralp = NULL; |
84 |
> |
int duped1 = -1; |
85 |
|
int rval; |
86 |
|
int i; |
87 |
|
/* global program name */ |
90 |
|
for (i = 0; addobjnotify[i] != NULL; i++) |
91 |
|
; |
92 |
|
addobjnotify[i] = tranotify; |
90 |
– |
/* set our defaults */ |
91 |
– |
maxdepth = -10; |
92 |
– |
minweight = 2e-3; |
93 |
|
/* option city */ |
94 |
|
for (i = 1; i < argc; i++) { |
95 |
|
/* expand arguments */ |
132 |
|
break; |
133 |
|
case 'w': /* warnings */ |
134 |
|
rval = erract[WARNING].pf != NULL; |
135 |
< |
bool(2,rval); |
135 |
> |
check_bool(2,rval); |
136 |
|
if (rval) erract[WARNING].pf = wputs; |
137 |
|
else erract[WARNING].pf = NULL; |
138 |
|
break; |
143 |
|
case 'l': /* limit distance */ |
144 |
|
if (argv[i][2] != 'd') |
145 |
|
goto badopt; |
146 |
< |
bool(3,lim_dist); |
146 |
> |
check_bool(3,lim_dist); |
147 |
|
break; |
148 |
|
case 'I': /* immed. irradiance */ |
149 |
< |
bool(2,imm_irrad); |
149 |
> |
check_bool(2,imm_irrad); |
150 |
|
break; |
151 |
|
case 'f': /* format i/o */ |
152 |
|
switch (argv[i][2]) { |
178 |
|
break; |
179 |
|
case 'h': /* header output */ |
180 |
|
rval = loadflags & IO_INFO; |
181 |
< |
bool(2,rval); |
181 |
> |
check_bool(2,rval); |
182 |
|
loadflags = rval ? loadflags | IO_INFO : |
183 |
|
loadflags & ~IO_INFO; |
184 |
|
break; |
192 |
|
tralp = tralist; |
193 |
|
} |
194 |
|
if (argv[i][2] == 'I') { /* file */ |
195 |
< |
rval = wordfile(tralp, |
195 |
> |
rval = wordfile(tralp, MAXMODLIST-(tralp-tralist), |
196 |
|
getpath(argv[++i],getrlibpath(),R_OK)); |
197 |
|
if (rval < 0) { |
198 |
|
sprintf(errmsg, |
214 |
|
tralp = tralist; |
215 |
|
} |
216 |
|
if (argv[i][2] == 'E') { /* file */ |
217 |
< |
rval = wordfile(tralp, |
217 |
> |
rval = wordfile(tralp, MAXMODLIST-(tralp-tralist), |
218 |
|
getpath(argv[++i],getrlibpath(),R_OK)); |
219 |
|
if (rval < 0) { |
220 |
|
sprintf(errmsg, |
251 |
|
if (nproc > 1) { |
252 |
|
if (persist) |
253 |
|
error(USER, "multiprocessing incompatible with persist file"); |
254 |
< |
if (hresolu > 0 && hresolu < nproc) |
254 |
> |
if (!vresolu && hresolu > 0 && hresolu < nproc) |
255 |
|
error(WARNING, "number of cores should not exceed horizontal resolution"); |
256 |
|
if (trace != NULL) |
257 |
|
error(WARNING, "multiprocessing does not work properly with trace mode"); |
313 |
|
#endif |
314 |
|
if (outform != 'a') |
315 |
|
SET_FILE_BINARY(stdout); |
316 |
< |
readoct(octnm, loadflags, &thescene, NULL); |
316 |
> |
rval = setrtoutput(); |
317 |
> |
readoct(octname = octnm, loadflags, &thescene, NULL); |
318 |
|
nsceneobjs = nobjects; |
319 |
|
|
320 |
|
if (loadflags & IO_INFO) { /* print header */ |
321 |
|
printargs(i, argv, stdout); |
322 |
|
printf("SOFTWARE= %s\n", VersionID); |
323 |
|
fputnow(stdout); |
324 |
+ |
if (rval > 0) /* saved from setrtoutput() call */ |
325 |
+ |
printf("NCOMP=%d\n", rval); |
326 |
+ |
if ((outform == 'f') | (outform == 'd')) |
327 |
+ |
fputendian(stdout); |
328 |
|
fputformat(formstr(outform), stdout); |
329 |
|
putchar('\n'); |
330 |
|
} |
331 |
< |
|
331 |
> |
|
332 |
> |
ray_init_pmap(); /* PMAP: set up & load photon maps */ |
333 |
> |
|
334 |
|
marksources(); /* find and mark sources */ |
335 |
|
|
336 |
|
setambient(); /* initialize ambient calculation */ |
337 |
< |
|
337 |
> |
|
338 |
|
#ifdef PERSIST |
339 |
|
if (persist) { |
340 |
|
fflush(stdout); |
380 |
|
goto runagain; |
381 |
|
} |
382 |
|
#endif |
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 |
|
|
468 |
|
if (imm_irrad) |
469 |
|
printf("-I+\t\t\t\t# immediate irradiance on\n"); |
470 |
|
printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc); |
471 |
< |
printf("-x %-9d\t\t\t# x resolution (flush interval)\n", hresolu); |
471 |
> |
printf("-x %-9d\t\t\t# %s\n", hresolu, |
472 |
> |
vresolu && hresolu ? "x resolution" : "flush interval"); |
473 |
|
printf("-y %-9d\t\t\t# y resolution\n", vresolu); |
474 |
|
printf(lim_dist ? "-ld+\t\t\t\t# limit distance on\n" : |
475 |
|
"-ld-\t\t\t\t# limit distance off\n"); |
483 |
|
case 't': case 'T': printf(" trace"); break; |
484 |
|
case 'o': printf(" origin"); break; |
485 |
|
case 'd': printf(" direction"); break; |
486 |
+ |
case 'r': printf(" reflect_contrib"); break; |
487 |
+ |
case 'R': printf(" reflect_length"); break; |
488 |
+ |
case 'x': printf(" unreflect_contrib"); break; |
489 |
+ |
case 'X': printf(" unreflect_length"); break; |
490 |
|
case 'v': printf(" value"); break; |
491 |
|
case 'V': printf(" contribution"); break; |
492 |
|
case 'l': printf(" length"); break; |