--- ray/src/rt/raytrace.c 2003/02/25 02:47:23 2.35 +++ ray/src/rt/raytrace.c 2003/05/09 22:18:03 2.39 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: raytrace.c,v 2.35 2003/02/25 02:47:23 greg Exp $"; +static const char RCSid[] = "$Id: raytrace.c,v 2.39 2003/05/09 22:18:03 greg Exp $"; #endif /* * raytrace.c - routines for tracing and shading rays. @@ -95,11 +95,13 @@ register RAY *r; { r->rno = raynum++; r->newcset = r->clipset; + r->hitf = rayhit; r->robj = OVOID; r->ro = NULL; r->rox = NULL; r->rt = r->rot = FHUGE; r->pert[0] = r->pert[1] = r->pert[2] = 0.0; + r->uv[0] = r->uv[1] = 0.0; setcolor(r->pcol, 1.0, 1.0, 1.0); setcolor(r->rcol, 0.0, 0.0, 0.0); } @@ -172,7 +174,8 @@ int mod; } ******/ /* hack for irradiance calculation */ - if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS))) { + if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS)) && + (ofun[m->otype].flags & (T_M|T_X))) { if (irr_ignore(m->otype)) { #if MAXLOOP depth--; @@ -225,9 +228,10 @@ register RAY *r; } +void raytexture(r, mod) /* get material modifiers */ RAY *r; -int mod; +OBJECT mod; { register OBJREC *m; #if MAXLOOP @@ -409,6 +413,22 @@ register RAY *r; } +void +rayhit(oset, r) /* standard ray hit test */ +OBJECT *oset; +RAY *r; +{ + OBJREC *o; + int i; + + for (i = oset[0]; i > 0; i--) { + o = objptr(oset[i]); + if ((*ofun[o->otype].funp)(o, r)) + r->robj = oset[i]; + } +} + + int localhit(r, scene) /* check for hit in the octree */ register RAY *r; @@ -564,17 +584,13 @@ CUBE *cu; OBJECT *cxs; { OBJECT oset[MAXSET+1]; - register OBJREC *o; - register int i; objset(oset, cu->cutree); - checkset(oset, cxs); /* eliminate double-checking */ - for (i = oset[0]; i > 0; i--) { - o = objptr(oset[i]); - if ((*ofun[o->otype].funp)(o, r)) - r->robj = oset[i]; - } - if (r->ro == NULL) + checkset(oset, cxs); /* avoid double-checking */ + + (*r->hitf)(oset, r); /* test for hit in set */ + + if (r->robj == OVOID) return(0); /* no scores yet */ return(incube(cu, r->rop)); /* hit OK if in current cube */