8 |
|
#include "copyright.h" |
9 |
|
|
10 |
|
#include <signal.h> |
11 |
+ |
#include <time.h> |
12 |
|
#include "rcontrib.h" |
13 |
< |
#include "platform.h" |
13 |
< |
#include "paths.h" |
13 |
> |
#include "random.h" |
14 |
|
#include "source.h" |
15 |
|
#include "ambient.h" |
16 |
+ |
#include "pmapray.h" |
17 |
+ |
#include "pmapcontrib.h" |
18 |
|
|
19 |
|
int gargc; /* global argc */ |
20 |
|
char **gargv; /* global argv */ |
43 |
|
int imm_irrad = 0; /* compute immediate irradiance? */ |
44 |
|
int lim_dist = 0; /* limit distance? */ |
45 |
|
|
46 |
< |
const char *modname[MAXMODLIST]; /* ordered modifier name list */ |
45 |
< |
int nmods = 0; /* number of modifiers */ |
46 |
> |
int report_intvl = 0; /* reporting interval (seconds) */ |
47 |
|
|
48 |
< |
char RCCONTEXT[] = "RCONTRIB"; /* our special evaluation context */ |
48 |
> |
char **modname = NULL; /* ordered modifier name list */ |
49 |
> |
int nmods = 0; /* number of modifiers */ |
50 |
> |
int modasiz = 0; /* allocated modifier array size */ |
51 |
|
|
52 |
< |
void (*addobjnotify[8])() = {ambnotify, tranotify, NULL}; |
52 |
> |
void (*addobjnotify[8])() = {ambnotify, NULL}; |
53 |
|
|
54 |
+ |
char RCCONTEXT[] = "RC."; /* our special evaluation context */ |
55 |
|
|
56 |
+ |
#if defined(_WIN32) || defined(_WIN64) |
57 |
+ |
#define RCONTRIB_FEATURES "Accumulation\nSummation\nRecovery\n" \ |
58 |
+ |
"ValueContribution\nImmediateIrradiance\n" \ |
59 |
+ |
"ProgressReporting\nDistanceLimiting\n" \ |
60 |
+ |
"Outputs=V,W\n" |
61 |
+ |
#else |
62 |
+ |
#define RCONTRIB_FEATURES "Multiprocessing\n" \ |
63 |
+ |
"Accumulation\nSummation\nRecovery\n" \ |
64 |
+ |
"ValueContribution\nImmediateIrradiance\n" \ |
65 |
+ |
"ProgressReporting\nDistanceLimiting\n" \ |
66 |
+ |
"Outputs=V,W\n" |
67 |
+ |
#endif |
68 |
+ |
|
69 |
|
static void |
70 |
|
printdefaults(void) /* print default values to stdout */ |
71 |
|
{ |
72 |
< |
char *cp; |
73 |
< |
|
72 |
> |
printf("-c %-5d\t\t\t# accumulated rays per record\n", accumulate); |
73 |
> |
printf("-V%c\t\t\t\t# output %s\n", contrib ? '+' : '-', |
74 |
> |
contrib ? "contributions" : "coefficients"); |
75 |
|
if (imm_irrad) |
76 |
|
printf("-I+\t\t\t\t# immediate irradiance on\n"); |
77 |
|
printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc); |
178 |
|
#define check(ol,al) if (argv[i][ol] || \ |
179 |
|
badarg(argc-i-1,argv+i+1,al)) \ |
180 |
|
goto badopt |
181 |
< |
#define bool(olen,var) switch (argv[i][olen]) { \ |
181 |
> |
#define check_bool(olen,var) switch (argv[i][olen]) { \ |
182 |
|
case '\0': var = !var; break; \ |
183 |
|
case 'y': case 'Y': case 't': case 'T': \ |
184 |
|
case '+': case '1': var = 1; break; \ |
185 |
|
case 'n': case 'N': case 'f': case 'F': \ |
186 |
|
case '-': case '0': var = 0; break; \ |
187 |
|
default: goto badopt; } |
170 |
– |
int nprocs = 1; |
188 |
|
char *curout = NULL; |
189 |
+ |
char *prms = NULL; |
190 |
|
char *binval = NULL; |
191 |
|
int bincnt = 0; |
192 |
|
int rval; |
195 |
|
progname = argv[0] = fixargv0(argv[0]); |
196 |
|
gargv = argv; |
197 |
|
gargc = argc; |
198 |
+ |
/* feature check only? */ |
199 |
+ |
strcat(RFeatureList, RCONTRIB_FEATURES); |
200 |
+ |
if (!strcmp(argv[1], "-features")) |
201 |
+ |
return feature_status(argc-2, argv+2); |
202 |
+ |
#if defined(_WIN32) || defined(_WIN64) |
203 |
+ |
_setmaxstdio(2048); /* increase file limit to maximum */ |
204 |
+ |
#endif |
205 |
|
/* initialize calcomp routines early */ |
206 |
|
initfunc(); |
207 |
< |
setcontext(RCCONTEXT); |
207 |
> |
calcontext(RCCONTEXT); |
208 |
|
/* option city */ |
209 |
|
for (i = 1; i < argc; i++) { |
210 |
|
/* expand arguments */ |
239 |
|
error(USER, "bad number of processes"); |
240 |
|
break; |
241 |
|
case 'V': /* output contributions */ |
242 |
< |
bool(2,contrib); |
242 |
> |
check_bool(2,contrib); |
243 |
|
break; |
244 |
|
case 'x': /* x resolution */ |
245 |
|
check(2,"i"); |
251 |
|
break; |
252 |
|
case 'w': /* warnings */ |
253 |
|
rval = (erract[WARNING].pf != NULL); |
254 |
< |
bool(2,rval); |
254 |
> |
check_bool(2,rval); |
255 |
|
if (rval) erract[WARNING].pf = wputs; |
256 |
|
else erract[WARNING].pf = NULL; |
257 |
|
break; |
262 |
|
case 'l': /* limit distance */ |
263 |
|
if (argv[i][2] != 'd') |
264 |
|
goto badopt; |
265 |
< |
bool(3,lim_dist); |
265 |
> |
check_bool(3,lim_dist); |
266 |
|
break; |
267 |
|
case 'I': /* immed. irradiance */ |
268 |
< |
bool(2,imm_irrad); |
268 |
> |
check_bool(2,imm_irrad); |
269 |
|
break; |
270 |
|
case 'f': /* file or force or format */ |
271 |
|
if (!argv[i][2]) { |
274 |
|
break; |
275 |
|
} |
276 |
|
if (argv[i][2] == 'o') { |
277 |
< |
bool(3,force_open); |
277 |
> |
check_bool(3,force_open); |
278 |
|
break; |
279 |
|
} |
280 |
|
setformat(argv[i]+2); |
288 |
|
accumulate = atoi(argv[++i]); |
289 |
|
break; |
290 |
|
case 'r': /* recover output */ |
291 |
< |
bool(2,recover); |
291 |
> |
check_bool(2,recover); |
292 |
|
break; |
293 |
|
case 'h': /* header output */ |
294 |
< |
bool(2,header); |
294 |
> |
check_bool(2,header); |
295 |
|
break; |
296 |
+ |
case 'p': /* parameter setting(s) */ |
297 |
+ |
check(2,"s"); |
298 |
+ |
set_eparams(prms = argv[++i]); |
299 |
+ |
break; |
300 |
|
case 'b': /* bin expression/count */ |
301 |
|
if (argv[i][2] == 'n') { |
302 |
|
check(3,"s"); |
308 |
|
break; |
309 |
|
case 'm': /* modifier name */ |
310 |
|
check(2,"s"); |
311 |
< |
addmodifier(argv[++i], curout, binval, bincnt); |
311 |
> |
addmodifier(argv[++i], curout, prms, binval, bincnt); |
312 |
|
break; |
313 |
|
case 'M': /* modifier file */ |
314 |
|
check(2,"s"); |
315 |
< |
addmodfile(argv[++i], curout, binval, bincnt); |
315 |
> |
addmodfile(argv[++i], curout, prms, binval, bincnt); |
316 |
|
break; |
317 |
+ |
case 't': /* reporting interval */ |
318 |
+ |
check(2,"i"); |
319 |
+ |
report_intvl = atoi(argv[++i]); |
320 |
+ |
break; |
321 |
|
default: |
322 |
|
goto badopt; |
323 |
|
} |
324 |
|
} |
325 |
+ |
if (nmods <= 0) |
326 |
+ |
error(USER, "missing required modifier argument"); |
327 |
|
/* override some option settings */ |
328 |
|
override_options(); |
329 |
|
/* initialize object types */ |
368 |
|
readoct(octname, ~(IO_FILES|IO_INFO), &thescene, NULL); |
369 |
|
nsceneobjs = nobjects; |
370 |
|
|
371 |
+ |
/* PMAP: set up & load photon maps */ |
372 |
+ |
ray_init_pmap(); |
373 |
+ |
|
374 |
|
marksources(); /* find and mark sources */ |
375 |
+ |
|
376 |
+ |
/* PMAP: init photon map for light source contributions */ |
377 |
+ |
initPmapContrib(&modconttab, nmods); |
378 |
|
|
379 |
|
setambient(); /* initialize ambient calculation */ |
380 |
< |
|
380 |
> |
|
381 |
|
rcontrib(); /* trace ray contributions (loop) */ |
382 |
|
|
383 |
|
ambsync(); /* flush ambient file */ |
384 |
|
|
385 |
+ |
/* PMAP: free photon maps */ |
386 |
+ |
ray_done_pmap(); |
387 |
+ |
|
388 |
|
quit(0); /* exit clean */ |
389 |
|
|
390 |
|
badopt: |
391 |
|
fprintf(stderr, |
392 |
< |
"Usage: %s [-n nprocs][-V][-r][-e expr][-f source][-o ospec][-b binv][-bn N] {-m mod | -M file} [rtrace options] octree\n", |
392 |
> |
"Usage: %s [-n nprocs][-V][-c count][-r][-e expr][-f source][-o ospec][-p p1=V1,p2=V2][-b binv][-bn N] {-m mod | -M file} [rtrace options] octree\n", |
393 |
|
progname); |
394 |
|
sprintf(errmsg, "command line error at '%s'", argv[i]); |
395 |
|
error(USER, errmsg); |
396 |
|
return(1); /* pro forma return */ |
397 |
|
|
398 |
|
#undef check |
399 |
< |
#undef bool |
399 |
> |
#undef check_bool |
400 |
|
} |
401 |
|
|
402 |
|
|