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