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.2 by greg, Tue Jul 16 15:56:46 1991 UTC vs.
Revision 2.6 by greg, Fri Sep 15 15:47:29 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1995 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 36 | Line 36 | register RAY  *r;
36   {
37          COLOR  mcolor;
38          RAY  nr;
39 +        int  rpure = 1;
40          register int  i;
41                                          /* check arguments */
42          if (m->oargs.nfargs != 3 || m->oargs.nsargs > 1)
43                  objerror(m, USER, "bad number of arguments");
44 <                                        /* check if source ray */
45 <        if (r->rsrc >= 0) {                     /* aiming for somebody */
46 <                if (source[r->rsrc].so != r->ro)
47 <                        return;                         /* but not us */
48 <        } else if (m->oargs.nsargs > 0) {       /* else call substitute? */
49 <                rayshade(r, modifier(m->oargs.sarg[0]));
50 <                return;
44 >                                        /* check for substitute material */
45 >        if (m->oargs.nsargs > 0 &&
46 >                        (r->rsrc < 0 || source[r->rsrc].so != r->ro)) {
47 >                if (!strcmp(m->oargs.sarg[0], VOIDID)) {
48 >                        raytrans(r);
49 >                        return(1);
50 >                }
51 >                return(rayshade(r, modifier(m->oargs.sarg[0])));
52          }
53 +                                        /* check for bad source ray */
54 +        if (r->rsrc >= 0 && source[r->rsrc].so != r->ro)
55 +                return(1);
56 +
57          if (r->rod < 0.)                /* back is black */
58 <                return;
58 >                return(1);
59                                          /* get modifiers */
60          raytexture(r, m->omod);
61                                          /* assign material color */
# Line 70 | Line 76 | register RAY  *r;
76                  double  pdot;
77  
78                  if (rayorigin(&nr, r, REFLECTED, bright(mcolor)) < 0)
79 <                        return;
80 <                pdot = raynormal(pnorm, r);     /* use textures */
81 <                for (i = 0; i < 3; i++)
82 <                        nr.rdir[i] = r->rdir[i] + 2.*pdot*pnorm[i];
79 >                        return(1);
80 >                if (DOT(r->pert,r->pert) > FTINY*FTINY) {
81 >                        pdot = raynormal(pnorm, r);     /* use textures */
82 >                        for (i = 0; i < 3; i++)
83 >                                nr.rdir[i] = r->rdir[i] + 2.*pdot*pnorm[i];
84 >                        rpure = 0;
85 >                }
86 >                                                /* check for penetration */
87 >                if (rpure || DOT(nr.rdir, r->ron) <= FTINY)
88 >                        for (i = 0; i < 3; i++)
89 >                                nr.rdir[i] = r->rdir[i] + 2.*r->rod*r->ron[i];
90          }
91          rayvalue(&nr);
92          multcolor(nr.rcol, mcolor);
93          addcolor(r->rcol, nr.rcol);
94 +        if (rpure && r->ro != NULL && isflat(r->ro->otype))
95 +                r->rt = r->rot + nr.rt;
96 +        return(1);
97   }
98  
99  
# Line 87 | Line 103 | register OBJREC  *o;
103   SRCREC  *s;
104   int  n;
105   {
106 <        FVECT  nv;
106 >        FVECT  nv, sc;
107          double  od;
108 +        register int  i, j;
109                                  /* get surface normal and offset */
110          od = getplaneq(nv, o);
111 <                                /* check for behind */
112 <        if (DOT(s->sloc, nv) <= (s->sflags & SDISTANT ? FTINY : od+FTINY))
111 >                                /* check for extreme point for behind */
112 >        VCOPY(sc, s->sloc);
113 >        for (i = s->sflags & SFLAT ? SV : SW; i >= 0; i--)
114 >                if (DOT(nv, s->ss[i]) > 0.)
115 >                        for (j = 0; j < 3; j++)
116 >                                sc[j] += s->ss[i][j];
117 >                else
118 >                        for (j = 0; j < 3; j++)
119 >                                sc[j] -= s->ss[i][j];
120 >        if (DOT(sc, nv) <= (s->sflags & SDISTANT ? FTINY : od+FTINY))
121                  return(0);
122                                  /* everything OK -- compute projection */
123          mirrorproj(pm, nv, od);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines