--- ray/src/rt/m_direct.c 1991/11/25 09:51:06 2.2 +++ ray/src/rt/m_direct.c 1994/12/20 20:18:17 2.5 @@ -1,4 +1,4 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1994 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -47,7 +47,7 @@ register RAY *r; { /* check if source ray */ if (r->rsrc >= 0 && source[r->rsrc].so != r->ro) - return; /* got the wrong guy */ + return(1); /* got the wrong guy */ /* compute first projection */ if (m->otype == MAT_DIRECT1 || (r->rsrc < 0 || source[r->rsrc].sa.sv.pn == 0)) @@ -56,6 +56,7 @@ register RAY *r; if (m->otype == MAT_DIRECT2 && (r->rsrc < 0 || source[r->rsrc].sa.sv.pn == 1)) redirect(m, r, 1); + return(1); } @@ -66,12 +67,33 @@ int n; { MFUNC *mf; register EPNODE **va; + FVECT nsdir; RAY nr; double coef; register int j; /* set up function */ mf = getdfunc(m); setfunc(m, r); + /* assign direction variable */ + if (r->rsrc >= 0) { + register SRCREC *sp = source + source[r->rsrc].sa.sv.sn; + + if (sp->sflags & SDISTANT) + VCOPY(nsdir, sp->sloc); + else { + for (j = 0; j < 3; j++) + nsdir[j] = sp->sloc[j] - r->rop[j]; + normalize(nsdir); + } + if (r->rox != NULL) + multv3(nsdir, nsdir, r->rox->b.xfm); + if (mf->b != &unitxf) + multv3(nsdir, nsdir, mf->b->xfm); + } else + nsdir[0] = nsdir[1] = nsdir[2] = 0.0; + varset("DxA", '=', nsdir[0]); + varset("DyA", '=', nsdir[1]); + varset("DzA", '=', nsdir[2]); /* compute coefficient */ errno = 0; va = mf->ep + 4*n; @@ -137,6 +159,7 @@ int n; olddot = DOT(tr.rdir, nv); if (olddot <= FTINY && olddot >= -FTINY) return(0); /* old dir parallels plane */ + tr.rmax = 0.0; rayorigin(&tr, NULL, PRIMARY, 1.0); if (!(*ofun[o->otype].funp)(o, &tr)) return(0); /* no intersection! */ @@ -144,6 +167,9 @@ int n; m = vsmaterial(o); mf = getdfunc(m); setfunc(m, &tr); + varset("DxA", '=', 0.0); + varset("DyA", '=', 0.0); + varset("DzA", '=', 0.0); errno = 0; va = mf->ep + 4*n; coef = evalue(va[0]);