1 |
|
#ifndef lint |
2 |
< |
static const char RCSid[] = "$Id$"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
4 |
|
/* |
5 |
|
* raytrace.c - routines for tracing and shading rays. |
95 |
|
{ |
96 |
|
r->rno = raynum++; |
97 |
|
r->newcset = r->clipset; |
98 |
+ |
r->hitf = rayhit; |
99 |
|
r->robj = OVOID; |
100 |
|
r->ro = NULL; |
101 |
|
r->rox = NULL; |
102 |
|
r->rt = r->rot = FHUGE; |
103 |
|
r->pert[0] = r->pert[1] = r->pert[2] = 0.0; |
104 |
+ |
r->uv[0] = r->uv[1] = 0.0; |
105 |
|
setcolor(r->pcol, 1.0, 1.0, 1.0); |
106 |
|
setcolor(r->rcol, 0.0, 0.0, 0.0); |
107 |
|
} |
174 |
|
} |
175 |
|
******/ |
176 |
|
/* hack for irradiance calculation */ |
177 |
< |
if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS))) { |
177 |
> |
if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS)) && |
178 |
> |
(ofun[m->otype].flags & (T_M|T_X))) { |
179 |
|
if (irr_ignore(m->otype)) { |
180 |
|
#if MAXLOOP |
181 |
|
depth--; |
412 |
|
} |
413 |
|
|
414 |
|
|
415 |
+ |
void |
416 |
+ |
rayhit(oset, r) /* standard ray hit test */ |
417 |
+ |
OBJECT *oset; |
418 |
+ |
RAY *r; |
419 |
+ |
{ |
420 |
+ |
OBJREC *o; |
421 |
+ |
int i; |
422 |
+ |
|
423 |
+ |
for (i = oset[0]; i > 0; i--) { |
424 |
+ |
o = objptr(oset[i]); |
425 |
+ |
if ((*ofun[o->otype].funp)(o, r)) |
426 |
+ |
r->robj = oset[i]; |
427 |
+ |
} |
428 |
+ |
} |
429 |
+ |
|
430 |
+ |
|
431 |
|
int |
432 |
|
localhit(r, scene) /* check for hit in the octree */ |
433 |
|
register RAY *r; |
583 |
|
OBJECT *cxs; |
584 |
|
{ |
585 |
|
OBJECT oset[MAXSET+1]; |
567 |
– |
register OBJREC *o; |
568 |
– |
register int i; |
586 |
|
|
587 |
|
objset(oset, cu->cutree); |
588 |
< |
checkset(oset, cxs); /* eliminate double-checking */ |
589 |
< |
for (i = oset[0]; i > 0; i--) { |
590 |
< |
o = objptr(oset[i]); |
591 |
< |
if ((*ofun[o->otype].funp)(o, r)) |
592 |
< |
r->robj = oset[i]; |
576 |
< |
} |
577 |
< |
if (r->ro == NULL) |
588 |
> |
checkset(oset, cxs); /* avoid double-checking */ |
589 |
> |
|
590 |
> |
(*r->hitf)(oset, r); /* test for hit in set */ |
591 |
> |
|
592 |
> |
if (r->robj == OVOID) |
593 |
|
return(0); /* no scores yet */ |
594 |
|
|
595 |
|
return(incube(cu, r->rop)); /* hit OK if in current cube */ |