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.1 by greg, Tue Jul 16 15:44:30 1991 UTC vs.
Revision 1.5 by greg, Thu Aug 8 11:30:05 1991 UTC

# Line 18 | Line 18 | static char SCCSid[] = "$SunId$ LBL";
18   /*
19   * The arguments for MAT_DIRECT1 are:
20   *
21 < *      4+ coef1 dx1 dy1 dz1 transform..
21 > *      5+ coef1 dx1 dy1 dz1 funcfile transform..
22   *      0
23   *      n A1 A2 .. An
24   *
25   * The arguments for MAT_DIRECT2 are:
26   *
27 < *      8+ coef1 dx1 dy1 dz1 coef2 dx2 dy2 dz2 transform..
27 > *      9+ coef1 dx1 dy1 dz1 coef2 dx2 dy2 dz2 funcfile transform..
28   *      0
29   *      n A1 A2 .. An
30   */
# Line 44 | Line 44 | register RAY  *r;
44                                          /* check if source ray */
45          if (r->rsrc >= 0 && source[r->rsrc].so != r->ro)
46                  return;                         /* got the wrong guy */
47 +        dir_check(m);
48                                          /* compute first projection */
49          if (m->otype == MAT_DIRECT1 ||
50                          (r->rsrc < 0 || source[r->rsrc].sa.sv.pn == 0))
# Line 65 | Line 66 | int  n;
66          double  coef;
67          register int  j;
68                                          /* set up function */
69 <        setfunc(m, r);
69 <        if (m->oargs.nsargs < 4+4*n)
70 <                objerror(m, USER, "too few arguments");
69 >        setmap(m, r, &((FULLXF *)m->os)->b);
70          sa = m->oargs.sarg + 4*n;
71                                          /* compute coefficient */
72          errno = 0;
# Line 80 | Line 79 | int  n;
79          errno = 0;
80          for (j = 0; j < 3; j++)
81                  nr.rdir[j] = varvalue(sa[j+1]);
82 <        if (errno || normalize(nr.rdir) == 0.0)
82 >        if (errno)
83                  goto computerr;
84 +        multv3(nr.rdir, nr.rdir, ((FULLXF *)m->os)->f.xfm);
85 +        if (r->rox != NULL)
86 +                multv3(nr.rdir, nr.rdir, r->rox->f.xfm);
87 +        if (normalize(nr.rdir) == 0.0)
88 +                goto computerr;
89                                          /* compute value */
90          if (r->rsrc >= 0)
91                  nr.rsrc = source[r->rsrc].sa.sv.sn;
# Line 109 | Line 113 | int  n;
113          register int  i, j;
114                                  /* get material arguments */
115          m = objptr(o->omod);
116 <        if (m->oargs.nsargs < 4+4*n)
113 <                objerror(m, USER, "too few arguments");
116 >        dir_check(m);
117          sa = m->oargs.sarg + 4*n;
118                                  /* initialize test ray */
119          getmaxdisk(cent, o);
# Line 122 | Line 125 | int  n;
125          else {
126                  for (i = 0; i < 3; i++) {
127                          tr.rdir[i] = cent[i] - s->sloc[i];
128 <                        tr.rorg[i] = cent[i] - .05*tr.rdir[i];
128 >                        tr.rorg[i] = s->sloc[i];
129                  }
130                  if (normalize(tr.rdir) == 0.0)
131                          return(0);              /* at source! */
# Line 135 | Line 138 | int  n;
138          if (!(*ofun[o->otype].funp)(o, &tr))
139                  return(0);              /* no intersection! */
140                                  /* compute redirection */
141 <        setfunc(m, &tr);
141 >        setmap(m, &tr, &((FULLXF *)m->os)->b);
142          errno = 0;
143          if (varvalue(sa[0]) <= FTINY)
144                  return(0);              /* insignificant */
# Line 145 | Line 148 | int  n;
148                  newdir[i] = varvalue(sa[i+1]);
149          if (errno)
150                  goto computerr;
151 +        multv3(newdir, newdir, ((FULLXF *)m->os)->f.xfm);
152 +                                        /* normalization unnecessary */
153          newdot = DOT(newdir, nv);
154          if (newdot <= FTINY && newdot >= -FTINY)
155                  return(0);              /* new dir parallels plane */
156                                  /* everything OK -- compute shear */
157          for (i = 0; i < 3; i++)
158 <                h[i] = tr.rdir[i]/olddot + newdir[i]/newdot;
158 >                h[i] = newdir[i]/newdot - tr.rdir[i]/olddot;
159          setident4(pm);
160          for (j = 0; j < 3; j++) {
161                  for (i = 0; i < 3; i++)
# Line 167 | Line 172 | int  n;
172   computerr:
173          objerror(m, WARNING, "projection compute error");
174          return(0);
175 + }
176 +
177 +
178 + static
179 + dir_check(m)                    /* check arguments and load function file */
180 + register OBJREC  *m;
181 + {
182 +        register FULLXF  *mxf;
183 +        register int  ff;
184 +
185 +        ff = m->otype == MAT_DIRECT1 ? 5 : 9;
186 +        if (ff > m->oargs.nsargs)
187 +                objerror(m, USER, "too few arguments");
188 +        funcfile(m->oargs.sarg[ff-1]);
189 +        if (m->os == NULL) {
190 +                mxf = (FULLXF *)malloc(sizeof(FULLXF));
191 +                if (mxf == NULL)
192 +                        error(SYSTEM, "out of memory in dir_check");
193 +                if (fullxf(mxf, m->oargs.nsargs-ff, m->oargs.sarg+ff) !=
194 +                                m->oargs.nsargs-ff)
195 +                        objerror(m, USER, "bad transform");
196 +                if (mxf->f.sca < 0.0)
197 +                        mxf->f.sca = -mxf->f.sca;
198 +                if (mxf->b.sca < 0.0)
199 +                        mxf->b.sca = -mxf->b.sca;
200 +                m->os = (char *)mxf;
201 +        }
202   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines