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; |
410 |
|
} |
411 |
|
|
412 |
|
|
413 |
+ |
void |
414 |
+ |
rayhit(oset, r) /* standard ray hit test */ |
415 |
+ |
OBJECT *oset; |
416 |
+ |
RAY *r; |
417 |
+ |
{ |
418 |
+ |
OBJREC *o; |
419 |
+ |
int i; |
420 |
+ |
|
421 |
+ |
for (i = oset[0]; i > 0; i--) { |
422 |
+ |
o = objptr(oset[i]); |
423 |
+ |
if ((*ofun[o->otype].funp)(o, r)) |
424 |
+ |
r->robj = oset[i]; |
425 |
+ |
} |
426 |
+ |
} |
427 |
+ |
|
428 |
+ |
|
429 |
|
int |
430 |
|
localhit(r, scene) /* check for hit in the octree */ |
431 |
|
register RAY *r; |
581 |
|
OBJECT *cxs; |
582 |
|
{ |
583 |
|
OBJECT oset[MAXSET+1]; |
567 |
– |
register OBJREC *o; |
568 |
– |
register int i; |
584 |
|
|
585 |
|
objset(oset, cu->cutree); |
586 |
< |
checkset(oset, cxs); /* eliminate double-checking */ |
587 |
< |
for (i = oset[0]; i > 0; i--) { |
588 |
< |
o = objptr(oset[i]); |
589 |
< |
if ((*ofun[o->otype].funp)(o, r)) |
590 |
< |
r->robj = oset[i]; |
576 |
< |
} |
577 |
< |
if (r->ro == NULL) |
586 |
> |
checkset(oset, cxs); /* avoid double-checking */ |
587 |
> |
|
588 |
> |
(*r->hitf)(oset, r); /* test for hit in set */ |
589 |
> |
|
590 |
> |
if (r->robj == OVOID) |
591 |
|
return(0); /* no scores yet */ |
592 |
|
|
593 |
|
return(incube(cu, r->rop)); /* hit OK if in current cube */ |