52 |
|
#endif |
53 |
|
OBJECT traset[MAXTSET+1]={0}; /* trace include/exclude set */ |
54 |
|
|
55 |
+ |
static int Tflag = 0; /* source tracing enabled? */ |
56 |
+ |
|
57 |
|
static RAY thisray; /* for our convenience */ |
58 |
|
|
59 |
|
static FILE *inpfp = NULL; /* input stream pointer */ |
121 |
|
} |
122 |
|
|
123 |
|
|
124 |
+ |
static void |
125 |
+ |
trace_sources(void) /* trace rays to light sources, also */ |
126 |
+ |
{ |
127 |
+ |
int sn; |
128 |
+ |
|
129 |
+ |
for (sn = 0; sn < nsources; sn++) |
130 |
+ |
source[sn].sflags |= SFOLLOW; |
131 |
+ |
} |
132 |
+ |
|
133 |
+ |
|
134 |
|
void |
135 |
|
rtrace( /* trace rays from file */ |
136 |
|
char *fname, |
160 |
|
/* set up output */ |
161 |
|
if (castonly || every_out[0] != NULL) |
162 |
|
nproc = 1; /* don't bother multiprocessing */ |
163 |
+ |
if (Tflag && every_out[0] != NULL) |
164 |
+ |
trace_sources(); /* asking to trace light sources */ |
165 |
|
if ((nextflush > 0) & (nproc > nextflush)) { |
166 |
|
error(WARNING, "reducing number of processes to match flush interval"); |
167 |
|
nproc = nextflush; |
231 |
|
} |
232 |
|
|
233 |
|
|
220 |
– |
static void |
221 |
– |
trace_sources(void) /* trace rays to light sources, also */ |
222 |
– |
{ |
223 |
– |
int sn; |
224 |
– |
|
225 |
– |
for (sn = 0; sn < nsources; sn++) |
226 |
– |
source[sn].sflags |= SFOLLOW; |
227 |
– |
} |
228 |
– |
|
229 |
– |
|
234 |
|
int |
235 |
|
setrtoutput(void) /* set up output tables, return #comp */ |
236 |
|
{ |
245 |
|
do |
246 |
|
switch (*vs) { |
247 |
|
case 'T': /* trace sources */ |
248 |
< |
if (!vs[1]) break; |
245 |
< |
trace_sources(); |
248 |
> |
Tflag++; |
249 |
|
/* fall through */ |
250 |
|
case 't': /* trace */ |
251 |
|
if (!vs[1]) break; |
423 |
|
) |
424 |
|
{ |
425 |
|
/* set up ray */ |
423 |
– |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
426 |
|
if (imm_irrad) { |
427 |
|
VSUM(thisray.rorg, org, dir, 1.1e-4); |
428 |
|
thisray.rdir[0] = -dir[0]; |
429 |
|
thisray.rdir[1] = -dir[1]; |
430 |
|
thisray.rdir[2] = -dir[2]; |
431 |
|
thisray.rmax = 0.0; |
430 |
– |
thisray.revf = rayirrad; |
432 |
|
} else { |
433 |
|
VCOPY(thisray.rorg, org); |
434 |
|
VCOPY(thisray.rdir, dir); |
435 |
|
thisray.rmax = dmax; |
435 |
– |
if (castonly) |
436 |
– |
thisray.revf = raycast; |
436 |
|
} |
437 |
+ |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
438 |
+ |
if (imm_irrad) |
439 |
+ |
thisray.revf = rayirrad; |
440 |
+ |
else if (castonly) |
441 |
+ |
thisray.revf = raycast; |
442 |
|
if (ray_pnprocs > 1) { /* multiprocessing FIFO? */ |
443 |
|
if (ray_fifo_in(&thisray) < 0) |
444 |
|
error(USER, "lost children"); |
769 |
|
|
770 |
|
|
771 |
|
static void |
772 |
< |
oputp( /* print point */ |
772 |
> |
oputp( /* print intersection point */ |
773 |
|
RAY *r |
774 |
|
) |
775 |
|
{ |
776 |
< |
if (r->rot < FHUGE*.99) |
773 |
< |
(*putreal)(r->rop, 3); |
774 |
< |
else |
775 |
< |
(*putreal)(vdummy, 3); |
776 |
> |
(*putreal)(r->rop, 3); /* set to ray origin if distant or no hit */ |
777 |
|
} |
778 |
|
|
779 |
|
|
782 |
|
RAY *r |
783 |
|
) |
784 |
|
{ |
785 |
< |
if (r->rot < FHUGE*.99) { |
785 |
< |
if (r->rflips & 1) { /* undo any flippin' flips */ |
786 |
< |
FVECT unrm; |
787 |
< |
unrm[0] = -r->ron[0]; |
788 |
< |
unrm[1] = -r->ron[1]; |
789 |
< |
unrm[2] = -r->ron[2]; |
790 |
< |
(*putreal)(unrm, 3); |
791 |
< |
} else |
792 |
< |
(*putreal)(r->ron, 3); |
793 |
< |
} else |
785 |
> |
if (r->ro == NULL) { /* zero vector if clipped or no hit */ |
786 |
|
(*putreal)(vdummy, 3); |
787 |
+ |
return; |
788 |
+ |
} |
789 |
+ |
if (r->rflips & 1) { /* undo any flippin' flips */ |
790 |
+ |
FVECT unrm; |
791 |
+ |
unrm[0] = -r->ron[0]; |
792 |
+ |
unrm[1] = -r->ron[1]; |
793 |
+ |
unrm[2] = -r->ron[2]; |
794 |
+ |
(*putreal)(unrm, 3); |
795 |
+ |
} else |
796 |
+ |
(*putreal)(r->ron, 3); |
797 |
|
} |
798 |
|
|
799 |
|
|
804 |
|
{ |
805 |
|
FVECT pnorm; |
806 |
|
|
807 |
< |
if (r->rot >= FHUGE*.99) { |
807 |
> |
if (r->ro == NULL) { /* clipped or no hit */ |
808 |
|
(*putreal)(vdummy, 3); |
809 |
|
return; |
810 |
|
} |