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.1 by greg, Tue Nov 12 17:10:36 1991 UTC

# Line 36 | Line 36 | int  dir_proj();
36   VSMATERIAL  direct1_vs = {dir_proj, 1};
37   VSMATERIAL  direct2_vs = {dir_proj, 2};
38  
39 + #define fndx(m)         ((m)->otype == MAT_DIRECT1 ? 4 : 8)
40  
41 +
42 + static
43 + dir_check(m)                    /* check arguments and load function file */
44 + register OBJREC  *m;
45 + {
46 +        register FULLXF  *mxf;
47 +        register int  ff;
48 +
49 +        ff = fndx(m)+1;
50 +        if (ff > m->oargs.nsargs)
51 +                objerror(m, USER, "too few arguments");
52 +        if (m->os == NULL) {
53 +                mxf = (FULLXF *)malloc(sizeof(FULLXF));
54 +                if (mxf == NULL)
55 +                        error(SYSTEM, "out of memory in dir_check");
56 +                if (fullxf(mxf, m->oargs.nsargs-ff, m->oargs.sarg+ff) !=
57 +                                m->oargs.nsargs-ff)
58 +                        objerror(m, USER, "bad transform");
59 +                if (mxf->f.sca < 0.0)
60 +                        mxf->f.sca = -mxf->f.sca;
61 +                if (mxf->b.sca < 0.0)
62 +                        mxf->b.sca = -mxf->b.sca;
63 +                m->os = (char *)mxf;
64 +        }
65 + }
66 +
67 +
68   m_direct(m, r)                  /* shade redirected ray */
69   register OBJREC  *m;
70   register RAY  *r;
# Line 66 | Line 94 | int  n;
94          double  coef;
95          register int  j;
96                                          /* set up function */
97 <        setfunc(m, r);
97 >        setmap(m, r, &((FULLXF *)m->os)->b);
98 >        funcfile(m->oargs.sarg[fndx(m)]);
99          sa = m->oargs.sarg + 4*n;
100                                          /* compute coefficient */
101          errno = 0;
# Line 79 | Line 108 | int  n;
108          errno = 0;
109          for (j = 0; j < 3; j++)
110                  nr.rdir[j] = varvalue(sa[j+1]);
111 <        if (errno || normalize(nr.rdir) == 0.0)
111 >        if (errno)
112                  goto computerr;
113 +        multv3(nr.rdir, nr.rdir, ((FULLXF *)m->os)->f.xfm);
114 +        if (r->rox != NULL)
115 +                multv3(nr.rdir, nr.rdir, r->rox->f.xfm);
116 +        if (normalize(nr.rdir) == 0.0)
117 +                goto computerr;
118                                          /* compute value */
119          if (r->rsrc >= 0)
120                  nr.rsrc = source[r->rsrc].sa.sv.sn;
# Line 107 | Line 141 | int  n;
141          double  olddot, newdot, od;
142          register int  i, j;
143                                  /* get material arguments */
144 <        m = objptr(o->omod);
144 >        m = vsmaterial(o);
145          dir_check(m);
146          sa = m->oargs.sarg + 4*n;
147                                  /* initialize test ray */
# Line 133 | Line 167 | int  n;
167          if (!(*ofun[o->otype].funp)(o, &tr))
168                  return(0);              /* no intersection! */
169                                  /* compute redirection */
170 <        setfunc(m, &tr);
170 >        setmap(m, &tr, &((FULLXF *)m->os)->b);
171 >        funcfile(m->oargs.sarg[fndx(m)]);
172          errno = 0;
173          if (varvalue(sa[0]) <= FTINY)
174                  return(0);              /* insignificant */
# Line 143 | Line 178 | int  n;
178                  newdir[i] = varvalue(sa[i+1]);
179          if (errno)
180                  goto computerr;
181 +        multv3(newdir, newdir, ((FULLXF *)m->os)->f.xfm);
182 +                                        /* normalization unnecessary */
183          newdot = DOT(newdir, nv);
184          if (newdot <= FTINY && newdot >= -FTINY)
185                  return(0);              /* new dir parallels plane */
186                                  /* everything OK -- compute shear */
187          for (i = 0; i < 3; i++)
188 <                h[i] = tr.rdir[i]/olddot + newdir[i]/newdot;
188 >                h[i] = newdir[i]/newdot - tr.rdir[i]/olddot;
189          setident4(pm);
190          for (j = 0; j < 3; j++) {
191                  for (i = 0; i < 3; i++)
# Line 165 | Line 202 | int  n;
202   computerr:
203          objerror(m, WARNING, "projection compute error");
204          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]);
205   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines