--- ray/src/rt/m_mirror.c 1991/07/16 15:56:46 1.2 +++ ray/src/rt/m_mirror.c 1992/11/20 12:09:16 2.2 @@ -40,14 +40,16 @@ register RAY *r; /* check arguments */ if (m->oargs.nfargs != 3 || m->oargs.nsargs > 1) objerror(m, USER, "bad number of arguments"); - /* check if source ray */ - if (r->rsrc >= 0) { /* aiming for somebody */ - if (source[r->rsrc].so != r->ro) - return; /* but not us */ - } else if (m->oargs.nsargs > 0) { /* else call substitute? */ + /* 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; } + /* check for bad source ray */ + if (r->rsrc >= 0 && source[r->rsrc].so != r->ro) + return; + if (r->rod < 0.) /* back is black */ return; /* get modifiers */ @@ -74,6 +76,10 @@ register RAY *r; pdot = raynormal(pnorm, r); /* use textures */ for (i = 0; i < 3; i++) nr.rdir[i] = r->rdir[i] + 2.*pdot*pnorm[i]; + /* check for penetration */ + if (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);