--- ray/src/rt/m_mirror.c 1992/11/20 12:09:16 2.2 +++ ray/src/rt/m_mirror.c 1995/09/15 15:47:29 2.6 @@ -1,4 +1,4 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1995 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -36,6 +36,7 @@ register RAY *r; { COLOR mcolor; RAY nr; + int rpure = 1; register int i; /* check arguments */ if (m->oargs.nfargs != 3 || m->oargs.nsargs > 1) @@ -43,15 +44,18 @@ register RAY *r; /* check for substitute material */ if (m->oargs.nsargs > 0 && (r->rsrc < 0 || source[r->rsrc].so != r->ro)) { - rayshade(r, modifier(m->oargs.sarg[0])); - return; + if (!strcmp(m->oargs.sarg[0], VOIDID)) { + raytrans(r); + return(1); + } + return(rayshade(r, modifier(m->oargs.sarg[0]))); } /* check for bad source ray */ if (r->rsrc >= 0 && source[r->rsrc].so != r->ro) - return; + return(1); if (r->rod < 0.) /* back is black */ - return; + return(1); /* get modifiers */ raytexture(r, m->omod); /* assign material color */ @@ -72,18 +76,24 @@ register RAY *r; double pdot; if (rayorigin(&nr, r, REFLECTED, bright(mcolor)) < 0) - return; - pdot = raynormal(pnorm, r); /* use textures */ - for (i = 0; i < 3; i++) - nr.rdir[i] = r->rdir[i] + 2.*pdot*pnorm[i]; + return(1); + if (DOT(r->pert,r->pert) > FTINY*FTINY) { + pdot = raynormal(pnorm, r); /* use textures */ + for (i = 0; i < 3; i++) + nr.rdir[i] = r->rdir[i] + 2.*pdot*pnorm[i]; + rpure = 0; + } /* check for penetration */ - if (DOT(nr.rdir, r->ron) <= FTINY) + if (rpure || DOT(nr.rdir, r->ron) <= FTINY) for (i = 0; i < 3; i++) nr.rdir[i] = r->rdir[i] + 2.*r->rod*r->ron[i]; } rayvalue(&nr); multcolor(nr.rcol, mcolor); addcolor(r->rcol, nr.rcol); + if (rpure && r->ro != NULL && isflat(r->ro->otype)) + r->rt = r->rot + nr.rt; + return(1); } @@ -93,12 +103,21 @@ register OBJREC *o; SRCREC *s; int n; { - FVECT nv; + FVECT nv, sc; double od; + register int i, j; /* get surface normal and offset */ od = getplaneq(nv, o); - /* check for behind */ - if (DOT(s->sloc, nv) <= (s->sflags & SDISTANT ? FTINY : od+FTINY)) + /* check for extreme point for behind */ + VCOPY(sc, s->sloc); + for (i = s->sflags & SFLAT ? SV : SW; i >= 0; i--) + if (DOT(nv, s->ss[i]) > 0.) + for (j = 0; j < 3; j++) + sc[j] += s->ss[i][j]; + else + for (j = 0; j < 3; j++) + sc[j] -= s->ss[i][j]; + if (DOT(sc, nv) <= (s->sflags & SDISTANT ? FTINY : od+FTINY)) return(0); /* everything OK -- compute projection */ mirrorproj(pm, nv, od);