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 2.10 by greg, Wed Mar 5 16:16:53 2003 UTC vs.
Revision 2.15 by greg, Tue Jul 8 18:25:00 2014 UTC

# Line 9 | Line 9 | static const char      RCSid[] = "$Id$";
9   #include "copyright.h"
10  
11   #include  "ray.h"
12
12   #include  "otypes.h"
13 <
13 > #include  "rtotypes.h"
14   #include  "source.h"
16
15   #include  "func.h"
16  
17   /*
# Line 30 | Line 28 | static const char      RCSid[] = "$Id$";
28   *      n A1 A2 .. An
29   */
30  
31 + static int redirect(OBJREC  *m, RAY  *r, int  n);
32 + static int dir_proj(MAT4  pm, OBJREC  *o, SRCREC  *s, int  n);
33  
34 static int  dir_proj();
35
34   VSMATERIAL  direct1_vs = {dir_proj, 1};
35   VSMATERIAL  direct2_vs = {dir_proj, 2};
36  
# Line 42 | Line 40 | VSMATERIAL  direct2_vs = {dir_proj, 2};
40  
41  
42   int
43 < m_direct(m, r)                  /* shade redirected ray */
44 < register OBJREC  *m;
45 < register RAY  *r;
43 > m_direct(                       /* shade redirected ray */
44 >        OBJREC  *m,
45 >        RAY  *r
46 > )
47   {
48                                          /* check if source ray */
49          if (r->rsrc >= 0 && source[r->rsrc].so != r->ro)
# Line 61 | Line 60 | register RAY  *r;
60   }
61  
62  
63 < int
64 < redirect(m, r, n)               /* compute n'th ray redirection */
65 < OBJREC  *m;
66 < RAY  *r;
67 < int  n;
63 > static int
64 > redirect(               /* compute n'th ray redirection */
65 >        OBJREC  *m,
66 >        RAY  *r,
67 >        int  n
68 > )
69   {
70          MFUNC  *mf;
71 <        register EPNODE  **va;
71 >        EPNODE  **va;
72          FVECT  nsdir;
73          RAY  nr;
74          double  coef;
75 <        register int  j;
75 >        int  j;
76                                          /* set up function */
77          mf = getdfunc(m);
78          setfunc(m, r);
79                                          /* assign direction variable */
80          if (r->rsrc >= 0) {
81 <                register SRCREC  *sp = source + source[r->rsrc].sa.sv.sn;
81 >                SRCREC  *sp = source + source[r->rsrc].sa.sv.sn;
82  
83                  if (sp->sflags & SDISTANT)
84                          VCOPY(nsdir, sp->sloc);
# Line 100 | Line 100 | int  n;
100          errno = 0;
101          va = mf->ep + 4*n;
102          coef = evalue(va[0]);
103 <        if (errno == EDOM || errno == ERANGE)
103 >        if ((errno == EDOM) | (errno == ERANGE))
104                  goto computerr;
105 <        if (coef <= FTINY || rayorigin(&nr, r, TRANS, coef) < 0)
105 >        setcolor(nr.rcoef, coef, coef, coef);
106 >        if (rayorigin(&nr, TRANS, r, nr.rcoef) < 0)
107                  return(0);
108          va++;                           /* compute direction */
109          for (j = 0; j < 3; j++) {
# Line 110 | Line 111 | int  n;
111                  if (errno == EDOM || errno == ERANGE)
112                          goto computerr;
113          }
114 <        if (mf->f != &unitxf)
115 <                multv3(nr.rdir, nr.rdir, mf->f->xfm);
114 >        if (mf->fxp != &unitxf)
115 >                multv3(nr.rdir, nr.rdir, mf->fxp->xfm);
116          if (r->rox != NULL)
117                  multv3(nr.rdir, nr.rdir, r->rox->f.xfm);
118          if (normalize(nr.rdir) == 0.0)
# Line 120 | Line 121 | int  n;
121          if (r->rsrc >= 0)
122                  nr.rsrc = source[r->rsrc].sa.sv.sn;
123          rayvalue(&nr);
124 <        scalecolor(nr.rcol, coef);
124 >        multcolor(nr.rcol, nr.rcoef);
125          addcolor(r->rcol, nr.rcol);
126          if (r->ro != NULL && isflat(r->ro->otype))
127                  r->rt = r->rot + nr.rt;
# Line 132 | Line 133 | computerr:
133  
134  
135   static int
136 < dir_proj(pm, o, s, n)           /* compute a director's projection */
137 < MAT4  pm;
138 < OBJREC  *o;
139 < SRCREC  *s;
140 < int  n;
136 > dir_proj(               /* compute a director's projection */
137 >        MAT4  pm,
138 >        OBJREC  *o,
139 >        SRCREC  *s,
140 >        int  n
141 > )
142   {
143          RAY  tr;
144          OBJREC  *m;
# Line 144 | Line 146 | int  n;
146          EPNODE  **va;
147          FVECT  cent, newdir, nv, h;
148          double  coef, olddot, newdot, od;
149 <        register int  i, j;
149 >        int  i, j;
150                                  /* initialize test ray */
151          getmaxdisk(cent, o);
152          if (s->sflags & SDISTANT)
# Line 165 | Line 167 | int  n;
167          if (olddot <= FTINY && olddot >= -FTINY)
168                  return(0);              /* old dir parallels plane */
169          tr.rmax = 0.0;
170 <        rayorigin(&tr, NULL, PRIMARY, 1.0);
170 >        rayorigin(&tr, PRIMARY, NULL, NULL);
171          if (!(*ofun[o->otype].funp)(o, &tr))
172                  return(0);              /* no intersection! */
173                                  /* compute redirection */
# Line 188 | Line 190 | int  n;
190                  if (errno == EDOM || errno == ERANGE)
191                          goto computerr;
192          }
193 <        if (mf->f != &unitxf)
194 <                multv3(newdir, newdir, mf->f->xfm);
193 >        if (mf->fxp != &unitxf)
194 >                multv3(newdir, newdir, mf->fxp->xfm);
195                                          /* normalization unnecessary */
196          newdot = DOT(newdir, nv);
197          if (newdot <= FTINY && newdot >= -FTINY)
# Line 203 | Line 205 | int  n;
205                          pm[i][j] += nv[i]*h[j];
206                  pm[3][j] = -od*h[j];
207          }
208 <        if (newdot > 0.0 ^ olddot > 0.0)        /* add mirroring */
208 >        if ((newdot > 0.0) ^ (olddot > 0.0))    /* add mirroring */
209                  for (j = 0; j < 3; j++) {
210                          for (i = 0; i < 3; i++)
211                                  pm[i][j] -= 2.*nv[i]*nv[j];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines