ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/m_mirror.c
(Generate patch)

Comparing ray/src/rt/m_mirror.c (file contents):
Revision 1.1 by greg, Thu Jun 20 13:44:35 1991 UTC vs.
Revision 2.3 by greg, Wed Jan 12 16:46:41 1994 UTC

# Line 40 | Line 40 | register RAY  *r;
40                                          /* check arguments */
41          if (m->oargs.nfargs != 3 || m->oargs.nsargs > 1)
42                  objerror(m, USER, "bad number of arguments");
43 <                                        /* check if source ray */
44 <        if (r->rsrc >= 0) {                     /* aiming for somebody */
45 <                if (source[r->rsrc].so != r->ro)
46 <                        return;                         /* but not us */
47 <        } else if (m->oargs.nsargs > 0) {       /* else call substitute? */
43 >                                        /* check for substitute material */
44 >        if (m->oargs.nsargs > 0 &&
45 >                        (r->rsrc < 0 || source[r->rsrc].so != r->ro)) {
46                  rayshade(r, modifier(m->oargs.sarg[0]));
47 <                return;
47 >                return(1);
48          }
49 +                                        /* check for bad source ray */
50 +        if (r->rsrc >= 0 && source[r->rsrc].so != r->ro)
51 +                return(1);
52 +
53          if (r->rod < 0.)                /* back is black */
54 <                return;
54 >                return(1);
55                                          /* get modifiers */
56          raytexture(r, m->omod);
57                                          /* assign material color */
# Line 64 | Line 66 | register RAY  *r;
66                  for (i = 0; i < 3; i++)
67                          nr.rdir[i] = r->rdir[i] + 2.*r->rod*r->ron[i];
68                                          /* source we're aiming for next */
69 <                nr.rsrc = source[r->rsrc].sa.svnext;
69 >                nr.rsrc = source[r->rsrc].sa.sv.sn;
70          } else {                                /* ordinary reflection */
71                  FVECT  pnorm;
72                  double  pdot;
73  
74                  if (rayorigin(&nr, r, REFLECTED, bright(mcolor)) < 0)
75 <                        return;
75 >                        return(1);
76                  pdot = raynormal(pnorm, r);     /* use textures */
77                  for (i = 0; i < 3; i++)
78                          nr.rdir[i] = r->rdir[i] + 2.*pdot*pnorm[i];
79 +                                                /* check for penetration */
80 +                if (DOT(nr.rdir, r->ron) <= FTINY)
81 +                        for (i = 0; i < 3; i++)
82 +                                nr.rdir[i] = r->rdir[i] + 2.*r->rod*r->ron[i];
83          }
84          rayvalue(&nr);
85          multcolor(nr.rcol, mcolor);
86          addcolor(r->rcol, nr.rcol);
87 +        return(1);
88   }
89  
90  
91   mir_proj(pm, o, s, n)           /* compute a mirror's projection */
92   MAT4  pm;
93   register OBJREC  *o;
94 < register SRCREC  *s;
94 > SRCREC  *s;
95   int  n;
96   {
97          FVECT  nv;
98          double  od;
99                                  /* get surface normal and offset */
100 <        if (sfun[o->otype].of->getpleq == NULL)
94 <                return(0);              /* reject non-planar case */
95 <        od = (*sfun[o->otype].of->getpleq)(nv, o);
100 >        od = getplaneq(nv, o);
101                                  /* check for behind */
102          if (DOT(s->sloc, nv) <= (s->sflags & SDISTANT ? FTINY : od+FTINY))
103                  return(0);
# Line 110 | Line 115 | double  offs;
115          register int  i, j;
116                                          /* assign matrix */
117          setident4(m);
118 <        for (i = 0; i < 3; i++)
119 <                for (j = 0; j < 3; j++)
118 >        for (j = 0; j < 3; j++) {
119 >                for (i = 0; i < 3; i++)
120                          m[i][j] -= 2.*nv[i]*nv[j];
116        for (j = 0; j < 3; j++)
121                  m[3][j] = 2.*offs*nv[j];
122 +        }
123   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines