74 |
|
|
75 |
|
int backvis = 1; /* back face visibility */ |
76 |
|
|
77 |
< |
int maxdepth = 8; /* maximum recursion depth */ |
77 |
> |
int maxdepth = -10; /* maximum recursion depth */ |
78 |
|
double minweight = 2e-3; /* minimum ray weight */ |
79 |
|
|
80 |
|
char *ambfile = NULL; /* ambient file name */ |
96 |
|
static putf_t puta, putd, putf; |
97 |
|
|
98 |
|
typedef void oputf_t(RAY *r); |
99 |
< |
static oputf_t oputo, oputd, oputv, oputl, oputL, oputc, |
100 |
< |
oputp, oputn, oputN, oputs, oputw, oputm, oputM; |
99 |
> |
static oputf_t oputo, oputd, oputv, oputl, oputL, oputc, oputp, |
100 |
> |
oputn, oputN, oputs, oputw, oputW, oputm, oputM, oputtilde; |
101 |
|
|
102 |
|
static void setoutput(char *vs); |
103 |
|
static void tranotify(OBJECT obj); |
148 |
|
char *fname |
149 |
|
) |
150 |
|
{ |
151 |
< |
long vcount = hresolu>1 ? hresolu*vresolu : vresolu; |
151 |
> |
unsigned long vcount = (hresolu > 1) ? (unsigned long)hresolu*vresolu |
152 |
> |
: vresolu; |
153 |
|
long nextflush = hresolu; |
154 |
|
FILE *fp; |
155 |
|
double d; |
161 |
|
sprintf(errmsg, "cannot open input file \"%s\"", fname); |
162 |
|
error(SYSTEM, errmsg); |
163 |
|
} |
163 |
– |
#ifdef _WIN32 |
164 |
|
if (inform != 'a') |
165 |
|
SET_FILE_BINARY(fp); |
166 |
– |
#endif |
166 |
|
/* set up output */ |
167 |
|
setoutput(outvals); |
168 |
|
switch (outform) { |
188 |
|
d = normalize(direc); |
189 |
|
if (d == 0.0) { /* zero ==> flush */ |
190 |
|
bogusray(); |
191 |
< |
if (--nextflush <= 0 || vcount <= 0) { |
191 |
> |
if (--nextflush <= 0 || !vcount) { |
192 |
|
fflush(stdout); |
193 |
|
nextflush = hresolu; |
194 |
|
} |
200 |
|
else |
201 |
|
rad(orig, direc, lim_dist ? d : 0.0); |
202 |
|
/* flush if time */ |
203 |
< |
if (--nextflush == 0) { |
203 |
> |
if (!--nextflush) { |
204 |
|
fflush(stdout); |
205 |
|
nextflush = hresolu; |
206 |
|
} |
207 |
|
} |
208 |
|
if (ferror(stdout)) |
209 |
|
error(SYSTEM, "write error"); |
210 |
< |
if (--vcount == 0) /* check for end */ |
210 |
> |
if (vcount && !--vcount) /* check for end */ |
211 |
|
break; |
212 |
|
} |
213 |
|
fflush(stdout); |
214 |
< |
if (vcount > 0) |
215 |
< |
error(USER, "read error"); |
214 |
> |
if (vcount) |
215 |
> |
error(USER, "unexpected EOF on input"); |
216 |
|
if (fname != NULL) |
217 |
|
fclose(fp); |
218 |
|
} |
219 |
|
|
220 |
|
|
221 |
|
static void |
222 |
+ |
trace_sources(void) /* trace rays to light sources, also */ |
223 |
+ |
{ |
224 |
+ |
int sn; |
225 |
+ |
|
226 |
+ |
for (sn = 0; sn < nsources; sn++) |
227 |
+ |
source[sn].sflags |= SFOLLOW; |
228 |
+ |
} |
229 |
+ |
|
230 |
+ |
|
231 |
+ |
static void |
232 |
|
setoutput( /* set up output tables */ |
233 |
|
register char *vs |
234 |
|
) |
238 |
|
castonly = 1; |
239 |
|
while (*vs) |
240 |
|
switch (*vs++) { |
241 |
+ |
case 'T': /* trace sources */ |
242 |
+ |
if (!*vs) break; |
243 |
+ |
trace_sources(); |
244 |
+ |
/* fall through */ |
245 |
|
case 't': /* trace */ |
246 |
+ |
if (!*vs) break; |
247 |
|
*table = NULL; |
248 |
|
table = every_out; |
249 |
|
trace = ourtrace; |
285 |
|
case 'w': /* weight */ |
286 |
|
*table++ = oputw; |
287 |
|
break; |
288 |
+ |
case 'W': /* coefficient */ |
289 |
+ |
*table++ = oputW; |
290 |
+ |
if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0)) |
291 |
+ |
error(WARNING, |
292 |
+ |
"-otW accuracy depends on -aa 0 -as 0"); |
293 |
+ |
break; |
294 |
|
case 'm': /* modifier */ |
295 |
|
*table++ = oputm; |
296 |
|
break; |
297 |
|
case 'M': /* material */ |
298 |
|
*table++ = oputM; |
299 |
|
break; |
300 |
+ |
case '~': /* tilde */ |
301 |
+ |
*table++ = oputtilde; |
302 |
+ |
break; |
303 |
|
} |
304 |
|
*table = NULL; |
305 |
|
} |
310 |
|
{ |
311 |
|
thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] = |
312 |
|
thisray.rdir[0] = thisray.rdir[1] = thisray.rdir[2] = 0.0; |
313 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
313 |
> |
thisray.rmax = 0.0; |
314 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
315 |
|
printvals(&thisray); |
316 |
|
} |
317 |
|
|
326 |
|
VCOPY(thisray.rorg, org); |
327 |
|
VCOPY(thisray.rdir, dir); |
328 |
|
thisray.rmax = dmax; |
329 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
329 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
330 |
|
if (castonly) { |
331 |
|
if (!localhit(&thisray, &thescene)) { |
332 |
|
if (thisray.ro == &Aftplane) { /* clipped */ |
353 |
|
thisray.rorg[i] = org[i] + dir[i]; |
354 |
|
thisray.rdir[i] = -dir[i]; |
355 |
|
} |
356 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
356 |
> |
thisray.rmax = 0.0; |
357 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
358 |
|
/* pretend we hit surface */ |
359 |
|
thisray.rot = 1.0-1e-4; |
360 |
|
thisray.rod = 1.0; |
467 |
|
tabin(r); |
468 |
|
for (tp = every_out; *tp != NULL; tp++) |
469 |
|
(**tp)(r); |
470 |
< |
putchar('\n'); |
470 |
> |
if (outform == 'a') |
471 |
> |
putchar('\n'); |
472 |
|
} |
473 |
|
|
474 |
|
|
477 |
|
RAY *r |
478 |
|
) |
479 |
|
{ |
480 |
< |
register RAY *rp; |
480 |
> |
const RAY *rp; |
481 |
|
|
482 |
|
for (rp = r->parent; rp != NULL; rp = rp->parent) |
483 |
|
putchar('\t'); |
511 |
|
RAY *r |
512 |
|
) |
513 |
|
{ |
488 |
– |
COLR cout; |
489 |
– |
|
514 |
|
if (outform == 'c') { |
515 |
+ |
COLR cout; |
516 |
|
setcolr(cout, colval(r->rcol,RED), |
517 |
|
colval(r->rcol,GRN), |
518 |
|
colval(r->rcol,BLU)); |
630 |
|
|
631 |
|
|
632 |
|
static void |
633 |
+ |
oputW( /* print contribution */ |
634 |
+ |
RAY *r |
635 |
+ |
) |
636 |
+ |
{ |
637 |
+ |
COLOR contr; |
638 |
+ |
|
639 |
+ |
raycontrib(contr, r, PRIMARY); |
640 |
+ |
(*putreal)(colval(contr,RED)); |
641 |
+ |
(*putreal)(colval(contr,GRN)); |
642 |
+ |
(*putreal)(colval(contr,BLU)); |
643 |
+ |
} |
644 |
+ |
|
645 |
+ |
|
646 |
+ |
static void |
647 |
|
oputm( /* print modifier */ |
648 |
|
RAY *r |
649 |
|
) |
674 |
|
} else |
675 |
|
putchar('*'); |
676 |
|
putchar('\t'); |
677 |
+ |
} |
678 |
+ |
|
679 |
+ |
|
680 |
+ |
static void |
681 |
+ |
oputtilde( /* output tilde (spacer) */ |
682 |
+ |
RAY *r |
683 |
+ |
) |
684 |
+ |
{ |
685 |
+ |
fputs("~\t", stdout); |
686 |
|
} |
687 |
|
|
688 |
|
|