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.5 by greg, Tue Dec 20 20:18:17 1994 UTC vs.
Revision 2.12 by schorsch, Tue Mar 30 16:13:01 2004 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1994 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Routines for light-redirecting materials and
6   *   their associated virtual light sources
7   */
8  
9 < #include  "ray.h"
9 > #include "copyright.h"
10  
11 + #include  "ray.h"
12   #include  "otypes.h"
13 <
13 > #include  "rtotypes.h"
14   #include  "source.h"
17
15   #include  "func.h"
16  
17   /*
# Line 31 | Line 28 | static char SCCSid[] = "$SunId$ LBL";
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  
35 int  dir_proj();
34   VSMATERIAL  direct1_vs = {dir_proj, 1};
35   VSMATERIAL  direct2_vs = {dir_proj, 2};
36  
# Line 41 | Line 39 | VSMATERIAL  direct2_vs = {dir_proj, 2};
39                                  getfunc(m, 8, 0xff, 1) )
40  
41  
42 < m_direct(m, r)                  /* shade redirected ray */
43 < register OBJREC  *m;
44 < register RAY  *r;
42 > extern int
43 > m_direct(                       /* shade redirected ray */
44 >        register OBJREC  *m,
45 >        register RAY  *r
46 > )
47   {
48                                          /* check if source ray */
49          if (r->rsrc >= 0 && source[r->rsrc].so != r->ro)
# Line 60 | Line 60 | register RAY  *r;
60   }
61  
62  
63 < redirect(m, r, n)               /* compute n'th ray redirection */
64 < OBJREC  *m;
65 < RAY  *r;
66 < 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;
# Line 85 | Line 87 | int  n;
87                                  nsdir[j] = sp->sloc[j] - r->rop[j];
88                          normalize(nsdir);
89                  }
90 <                if (r->rox != NULL)
91 <                        multv3(nsdir, nsdir, r->rox->b.xfm);
92 <                if (mf->b != &unitxf)
93 <                        multv3(nsdir, nsdir, mf->b->xfm);
94 <        } else
95 <                nsdir[0] = nsdir[1] = nsdir[2] = 0.0;
96 <        varset("DxA", '=', nsdir[0]);
97 <        varset("DyA", '=', nsdir[1]);
98 <        varset("DzA", '=', nsdir[2]);
90 >                multv3(nsdir, nsdir, funcxf.xfm);
91 >                varset("DxA", '=', nsdir[0]/funcxf.sca);
92 >                varset("DyA", '=', nsdir[1]/funcxf.sca);
93 >                varset("DzA", '=', nsdir[2]/funcxf.sca);
94 >        } else {
95 >                varset("DxA", '=', 0.0);
96 >                varset("DyA", '=', 0.0);
97 >                varset("DzA", '=', 0.0);
98 >        }
99                                          /* compute coefficient */
100          errno = 0;
101          va = mf->ep + 4*n;
102          coef = evalue(va[0]);
103 <        if (errno)
103 >        if (errno == EDOM || errno == ERANGE)
104                  goto computerr;
105          if (coef <= FTINY || rayorigin(&nr, r, TRANS, coef) < 0)
106                  return(0);
107          va++;                           /* compute direction */
108          for (j = 0; j < 3; j++) {
109                  nr.rdir[j] = evalue(va[j]);
110 <                if (errno)
110 >                if (errno == EDOM || errno == ERANGE)
111                          goto computerr;
112          }
113          if (mf->f != &unitxf)
# Line 120 | Line 122 | int  n;
122          rayvalue(&nr);
123          scalecolor(nr.rcol, coef);
124          addcolor(r->rcol, nr.rcol);
125 +        if (r->ro != NULL && isflat(r->ro->otype))
126 +                r->rt = r->rot + nr.rt;
127          return(1);
128   computerr:
129          objerror(m, WARNING, "compute error");
# Line 127 | Line 131 | computerr:
131   }
132  
133  
134 < dir_proj(pm, o, s, n)           /* compute a director's projection */
135 < MAT4  pm;
136 < OBJREC  *o;
137 < SRCREC  *s;
138 < int  n;
134 > static int
135 > dir_proj(               /* compute a director's projection */
136 >        MAT4  pm,
137 >        OBJREC  *o,
138 >        SRCREC  *s,
139 >        int  n
140 > )
141   {
142          RAY  tr;
143          OBJREC  *m;
# Line 173 | Line 179 | int  n;
179          errno = 0;
180          va = mf->ep + 4*n;
181          coef = evalue(va[0]);
182 <        if (errno)
182 >        if (errno == EDOM || errno == ERANGE)
183                  goto computerr;
184          if (coef <= FTINY)
185                  return(0);              /* insignificant */
186          va++;
187          for (i = 0; i < 3; i++) {
188                  newdir[i] = evalue(va[i]);
189 <                if (errno)
189 >                if (errno == EDOM || errno == ERANGE)
190                          goto computerr;
191          }
192          if (mf->f != &unitxf)
# Line 198 | Line 204 | int  n;
204                          pm[i][j] += nv[i]*h[j];
205                  pm[3][j] = -od*h[j];
206          }
207 <        if (newdot > 0.0 ^ olddot > 0.0)        /* add mirroring */
207 >        if ((newdot > 0.0) ^ (olddot > 0.0))    /* add mirroring */
208                  for (j = 0; j < 3; j++) {
209                          for (i = 0; i < 3; i++)
210                                  pm[i][j] -= 2.*nv[i]*nv[j];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines