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 |
> |
|
41 |
|
int inform = 'a'; /* input format */ |
42 |
|
int outform = 'a'; /* output format */ |
43 |
|
char *outvals = "v"; /* output specification */ |
45 |
|
int hresolu = 0; /* horizontal (scan) size */ |
46 |
|
int vresolu = 0; /* vertical resolution */ |
47 |
|
|
48 |
+ |
extern int castonly; /* only doing ray-casting? */ |
49 |
+ |
|
50 |
|
int imm_irrad = 0; /* compute immediate irradiance? */ |
51 |
|
int lim_dist = 0; /* limit distance? */ |
52 |
|
|
66 |
|
static void sigdie(int signo, char *msg); |
67 |
|
static void printdefaults(void); |
68 |
|
|
69 |
+ |
#ifdef PERSIST |
70 |
+ |
#define RTRACE_FEATURES "Persist\nParallelPersist\nMultiProcessing\n" \ |
71 |
+ |
"IrradianceCalc\nImmediateIrradiance\nDistanceLimiting\n" \ |
72 |
+ |
"HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" |
73 |
+ |
#else |
74 |
+ |
#define RTRACE_FEATURES "IrradianceCalc\nIrradianceCalc\nDistanceLimiting\n" \ |
75 |
+ |
"HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" |
76 |
+ |
#endif |
77 |
|
|
78 |
+ |
|
79 |
|
int |
80 |
|
main(int argc, char *argv[]) |
81 |
|
{ |
98 |
|
int i; |
99 |
|
/* global program name */ |
100 |
|
progname = argv[0] = fixargv0(argv[0]); |
101 |
+ |
/* feature check only? */ |
102 |
+ |
strcat(RFeatureList, RTRACE_FEATURES); |
103 |
+ |
if (!strcmp(argv[1], "-features")) |
104 |
+ |
return feature_status(argc-2, argv+2); |
105 |
|
/* add trace notify function */ |
106 |
|
for (i = 0; addobjnotify[i] != NULL; i++) |
107 |
|
; |
108 |
|
addobjnotify[i] = tranotify; |
92 |
– |
/* set our defaults */ |
93 |
– |
rand_samp = 1; |
94 |
– |
maxdepth = -10; |
95 |
– |
minweight = 2e-3; |
109 |
|
/* option city */ |
110 |
|
for (i = 1; i < argc; i++) { |
111 |
|
/* expand arguments */ |
208 |
|
tralp = tralist; |
209 |
|
} |
210 |
|
if (argv[i][2] == 'I') { /* file */ |
211 |
< |
rval = wordfile(tralp, |
211 |
> |
rval = wordfile(tralp, MAXMODLIST-(tralp-tralist), |
212 |
|
getpath(argv[++i],getrlibpath(),R_OK)); |
213 |
|
if (rval < 0) { |
214 |
|
sprintf(errmsg, |
230 |
|
tralp = tralist; |
231 |
|
} |
232 |
|
if (argv[i][2] == 'E') { /* file */ |
233 |
< |
rval = wordfile(tralp, |
233 |
> |
rval = wordfile(tralp, MAXMODLIST-(tralp-tralist), |
234 |
|
getpath(argv[++i],getrlibpath(),R_OK)); |
235 |
|
if (rval < 0) { |
236 |
|
sprintf(errmsg, |
264 |
|
goto badopt; |
265 |
|
} |
266 |
|
} |
267 |
< |
if (nproc > 1) { |
268 |
< |
if (persist) |
256 |
< |
error(USER, "multiprocessing incompatible with persist file"); |
257 |
< |
if (!vresolu && hresolu > 0 && hresolu < nproc) |
258 |
< |
error(WARNING, "number of cores should not exceed horizontal resolution"); |
259 |
< |
if (trace != NULL) |
260 |
< |
error(WARNING, "multiprocessing does not work properly with trace mode"); |
261 |
< |
} |
267 |
> |
if (nproc > 1 && persist) |
268 |
> |
error(USER, "multiprocessing incompatible with persist file"); |
269 |
|
/* initialize object types */ |
270 |
|
initotypes(); |
271 |
|
/* initialize urand */ |
323 |
|
#endif |
324 |
|
if (outform != 'a') |
325 |
|
SET_FILE_BINARY(stdout); |
326 |
+ |
rval = setrtoutput(); |
327 |
|
readoct(octname = octnm, loadflags, &thescene, NULL); |
328 |
|
nsceneobjs = nobjects; |
329 |
|
|
331 |
|
printargs(i, argv, stdout); |
332 |
|
printf("SOFTWARE= %s\n", VersionID); |
333 |
|
fputnow(stdout); |
334 |
+ |
if (rval > 0) /* saved from setrtoutput() call */ |
335 |
+ |
printf("NCOMP=%d\n", rval); |
336 |
+ |
if ((outform == 'f') | (outform == 'd')) |
337 |
+ |
fputendian(stdout); |
338 |
|
fputformat(formstr(outform), stdout); |
339 |
|
putchar('\n'); |
340 |
|
} |
329 |
– |
|
330 |
– |
ray_init_pmap(); /* PMAP: set up & load photon maps */ |
331 |
– |
|
332 |
– |
marksources(); /* find and mark sources */ |
341 |
|
|
342 |
< |
setambient(); /* initialize ambient calculation */ |
343 |
< |
|
342 |
> |
if (!castonly) { /* any actual ray traversal to do? */ |
343 |
> |
|
344 |
> |
ray_init_pmap(); /* PMAP: set up & load photon maps */ |
345 |
> |
|
346 |
> |
marksources(); /* find and mark sources */ |
347 |
> |
|
348 |
> |
setambient(); /* initialize ambient calculation */ |
349 |
> |
} else |
350 |
> |
distantsources(); /* else mark only distant sources */ |
351 |
> |
|
352 |
> |
fflush(stdout); /* in case we're duplicating header */ |
353 |
> |
|
354 |
|
#ifdef PERSIST |
355 |
|
if (persist) { |
338 |
– |
fflush(stdout); |
356 |
|
/* reconnect stdout */ |
357 |
|
dup2(duped1, fileno(stdout)); |
358 |
|
close(duped1); |
423 |
|
|
424 |
|
void |
425 |
|
eputs( /* put string to stderr */ |
426 |
< |
register char *s |
426 |
> |
char *s |
427 |
|
) |
428 |
|
{ |
429 |
|
static int midline = 0; |
478 |
|
static void |
479 |
|
printdefaults(void) /* print default values to stdout */ |
480 |
|
{ |
481 |
< |
register char *cp; |
481 |
> |
char *cp; |
482 |
|
|
483 |
|
if (imm_irrad) |
484 |
|
printf("-I+\t\t\t\t# immediate irradiance on\n"); |
498 |
|
case 't': case 'T': printf(" trace"); break; |
499 |
|
case 'o': printf(" origin"); break; |
500 |
|
case 'd': printf(" direction"); break; |
501 |
+ |
case 'r': printf(" reflect_contrib"); break; |
502 |
+ |
case 'R': printf(" reflect_length"); break; |
503 |
+ |
case 'x': printf(" unreflect_contrib"); break; |
504 |
+ |
case 'X': printf(" unreflect_length"); break; |
505 |
|
case 'v': printf(" value"); break; |
506 |
|
case 'V': printf(" contribution"); break; |
507 |
|
case 'l': printf(" length"); break; |
514 |
|
case 'W': printf(" coefficient"); break; |
515 |
|
case 'm': printf(" modifier"); break; |
516 |
|
case 'M': printf(" material"); break; |
517 |
< |
case '-': printf(" stroke"); break; |
517 |
> |
case '~': printf(" tilde"); break; |
518 |
|
} |
519 |
|
putchar('\n'); |
520 |
|
printf(erract[WARNING].pf != NULL ? |