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

Comparing ray/src/rt/m_direct.c (file contents):
Revision 1.3 by greg, Tue Jul 16 17:16:32 1991 UTC vs.
Revision 2.2 by greg, Mon Nov 25 09:51:06 1991 UTC

# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15  
16   #include  "source.h"
17  
18 + #include  "func.h"
19 +
20   /*
21   * The arguments for MAT_DIRECT1 are:
22   *
# Line 30 | Line 32 | static char SCCSid[] = "$SunId$ LBL";
32   */
33  
34  
33 extern double  varvalue();
34
35   int  dir_proj();
36   VSMATERIAL  direct1_vs = {dir_proj, 1};
37   VSMATERIAL  direct2_vs = {dir_proj, 2};
38  
39 + #define getdfunc(m)     ( (m)->otype == MAT_DIRECT1 ? \
40 +                                getfunc(m, 4, 0xf, 1) : \
41 +                                getfunc(m, 8, 0xff, 1) )
42  
43 +
44   m_direct(m, r)                  /* shade redirected ray */
45   register OBJREC  *m;
46   register RAY  *r;
# Line 44 | Line 48 | register RAY  *r;
48                                          /* check if source ray */
49          if (r->rsrc >= 0 && source[r->rsrc].so != r->ro)
50                  return;                         /* got the wrong guy */
47        dir_check(m);
51                                          /* compute first projection */
52          if (m->otype == MAT_DIRECT1 ||
53                          (r->rsrc < 0 || source[r->rsrc].sa.sv.pn == 0))
# Line 61 | Line 64 | OBJREC  *m;
64   RAY  *r;
65   int  n;
66   {
67 <        register char  **sa;
67 >        MFUNC  *mf;
68 >        register EPNODE  **va;
69          RAY  nr;
70          double  coef;
71          register int  j;
72                                          /* set up function */
73 +        mf = getdfunc(m);
74          setfunc(m, r);
70        sa = m->oargs.sarg + 4*n;
75                                          /* compute coefficient */
76          errno = 0;
77 <        coef = varvalue(sa[0]);
77 >        va = mf->ep + 4*n;
78 >        coef = evalue(va[0]);
79          if (errno)
80                  goto computerr;
81          if (coef <= FTINY || rayorigin(&nr, r, TRANS, coef) < 0)
82                  return(0);
83 <                                        /* compute direction */
84 <        errno = 0;
85 <        for (j = 0; j < 3; j++)
86 <                nr.rdir[j] = varvalue(sa[j+1]);
87 <        if (errno || normalize(nr.rdir) == 0.0)
83 >        va++;                           /* compute direction */
84 >        for (j = 0; j < 3; j++) {
85 >                nr.rdir[j] = evalue(va[j]);
86 >                if (errno)
87 >                        goto computerr;
88 >        }
89 >        if (mf->f != &unitxf)
90 >                multv3(nr.rdir, nr.rdir, mf->f->xfm);
91 >        if (r->rox != NULL)
92 >                multv3(nr.rdir, nr.rdir, r->rox->f.xfm);
93 >        if (normalize(nr.rdir) == 0.0)
94                  goto computerr;
95                                          /* compute value */
96          if (r->rsrc >= 0)
# Line 101 | Line 112 | SRCREC  *s;
112   int  n;
113   {
114          RAY  tr;
115 <        register OBJREC  *m;
116 <        char  **sa;
115 >        OBJREC  *m;
116 >        MFUNC  *mf;
117 >        EPNODE  **va;
118          FVECT  cent, newdir, nv, h;
119 <        double  olddot, newdot, od;
119 >        double  coef, olddot, newdot, od;
120          register int  i, j;
109                                /* get material arguments */
110        m = objptr(o->omod);
111        dir_check(m);
112        sa = m->oargs.sarg + 4*n;
121                                  /* initialize test ray */
122          getmaxdisk(cent, o);
123          if (s->sflags & SDISTANT)
# Line 133 | Line 141 | int  n;
141          if (!(*ofun[o->otype].funp)(o, &tr))
142                  return(0);              /* no intersection! */
143                                  /* compute redirection */
144 +        m = vsmaterial(o);
145 +        mf = getdfunc(m);
146          setfunc(m, &tr);
147          errno = 0;
148 <        if (varvalue(sa[0]) <= FTINY)
149 <                return(0);              /* insignificant */
148 >        va = mf->ep + 4*n;
149 >        coef = evalue(va[0]);
150          if (errno)
151                  goto computerr;
152 <        for (i = 0; i < 3; i++)
153 <                newdir[i] = varvalue(sa[i+1]);
154 <        if (errno)
155 <                goto computerr;
152 >        if (coef <= FTINY)
153 >                return(0);              /* insignificant */
154 >        va++;
155 >        for (i = 0; i < 3; i++) {
156 >                newdir[i] = evalue(va[i]);
157 >                if (errno)
158 >                        goto computerr;
159 >        }
160 >        if (mf->f != &unitxf)
161 >                multv3(newdir, newdir, mf->f->xfm);
162 >                                        /* normalization unnecessary */
163          newdot = DOT(newdir, nv);
164          if (newdot <= FTINY && newdot >= -FTINY)
165                  return(0);              /* new dir parallels plane */
166                                  /* everything OK -- compute shear */
167          for (i = 0; i < 3; i++)
168 <                h[i] = tr.rdir[i]/olddot + newdir[i]/newdot;
168 >                h[i] = newdir[i]/newdot - tr.rdir[i]/olddot;
169          setident4(pm);
170          for (j = 0; j < 3; j++) {
171                  for (i = 0; i < 3; i++)
# Line 165 | Line 182 | int  n;
182   computerr:
183          objerror(m, WARNING, "projection compute error");
184          return(0);
168 }
169
170
171 static
172 dir_check(m)                    /* check arguments and load function file */
173 register OBJREC  *m;
174 {
175        register int  ff;
176
177        ff = m->otype == MAT_DIRECT1 ? 4 : 8;
178        if (ff >= m->oargs.nsargs)
179                objerror(m, USER, "too few arguments");
180        if (!vardefined(m->oargs.sarg[0]))
181                loadfunc(m->oargs.sarg[ff]);
185   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines