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

Comparing ray/src/rt/func.c (file contents):
Revision 1.11 by greg, Wed Dec 12 21:57:50 1990 UTC vs.
Revision 1.12 by greg, Sat Dec 15 15:03:26 1990 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1990 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #include  "otypes.h"
16  
17  
18 < typedef struct {
19 <        double  xfm[4][4];              /* transform matrix */
20 <        double  sca;                    /* scalefactor */
21 < }  XF;
18 > XF  funcxf;                     /* current transformation */
19 > static OBJREC  *fobj = NULL;    /* current function object */
20 > static RAY  *fray = NULL;       /* current function ray */
21  
23 static OBJREC  *fobj;           /* current function object */
24 static RAY  *fray;              /* current function ray */
25 static XF  fxf;                 /* current transformation */
22  
23 <
28 < setmap(m, r, xfm, sca)          /* set channels for function call */
23 > setmap(m, r, bx)                /* set channels for function call */
24   OBJREC  *m;
25   register RAY  *r;
26 < double  xfm[4][4];
32 < double  sca;
26 > XF  *bx;
27   {
28          extern double  l_noise3(), l_noise3a(), l_noise3b(), l_noise3c();
29          extern double  l_hermite(), l_fnoise3(), l_arg();
30          extern long  eclock;
31          static char  *initfile = "rayinit.cal";
32 <
32 >        static long  lastrno = -1;
33 >                                        /* check to see if already set */
34 >        if (m == fobj && r->rno == lastrno)
35 >                return;
36 >                                        /* initialize if first call */
37          if (initfile != NULL) {
38                  loadfunc(initfile);
39                  scompile("Dx=$1;Dy=$2;Dz=$3;", NULL, 0);
# Line 57 | Line 55 | double  sca;
55          }
56          fobj = m;
57          fray = r;
58 <        fxf.sca = r->robs * sca;
59 <        multmat4(fxf.xfm, r->robx, xfm);
58 >        lastrno = r->rno;
59 >        if (r->rox != NULL) {
60 >                funcxf.sca = r->rox->b.sca * bx->sca;
61 >                multmat4(funcxf.xfm, r->rox->b.xfm, bx->xfm);
62 >        } else
63 >                copystruct(&funcxf, bx);
64          eclock++;               /* notify expression evaluator */
65   }
66  
# Line 79 | Line 81 | RAY  *r;
81                  mxf = (XF *)malloc(sizeof(XF));
82                  if (mxf == NULL)
83                          goto memerr;
84 <                if (invxf(mxf->xfm, &mxf->sca, n, sa) != n)
84 >                if (invxf(mxf, n, sa) != n)
85                          objerror(m, USER, "bad transform");
86                  if (mxf->sca < 0.0)
87                          mxf->sca = -mxf->sca;
88                  m->os = (char *)mxf;
89          }
90 <        setmap(m, r, mxf->xfm, mxf->sca);
90 >        setmap(m, r, mxf);
91          return;
92   memerr:
93          error(SYSTEM, "out of memory in setfunc");
# Line 137 | Line 139 | register int  n;
139  
140          if (n < 3)                      /* ray direction */
141  
142 <                return( (       fray->rdir[0]*fxf.xfm[0][n] +
143 <                                fray->rdir[1]*fxf.xfm[1][n] +
144 <                                fray->rdir[2]*fxf.xfm[2][n]     )
145 <                         / fxf.sca );
142 >                return( (       fray->rdir[0]*funcxf.xfm[0][n] +
143 >                                fray->rdir[1]*funcxf.xfm[1][n] +
144 >                                fray->rdir[2]*funcxf.xfm[2][n]  )
145 >                         / funcxf.sca );
146  
147          if (n < 6)                      /* surface normal */
148  
149 <                return( (       fray->ron[0]*fxf.xfm[0][n-3] +
150 <                                fray->ron[1]*fxf.xfm[1][n-3] +
151 <                                fray->ron[2]*fxf.xfm[2][n-3]    )
152 <                         / fxf.sca );
149 >                return( (       fray->ron[0]*funcxf.xfm[0][n-3] +
150 >                                fray->ron[1]*funcxf.xfm[1][n-3] +
151 >                                fray->ron[2]*funcxf.xfm[2][n-3] )
152 >                         / funcxf.sca );
153  
154          if (n < 9)                      /* intersection */
155  
156 <                return( fray->rop[0]*fxf.xfm[0][n-6] +
157 <                                fray->rop[1]*fxf.xfm[1][n-6] +
158 <                                fray->rop[2]*fxf.xfm[2][n-6] +
159 <                                             fxf.xfm[3][n-6] );
156 >                return( fray->rop[0]*funcxf.xfm[0][n-6] +
157 >                                fray->rop[1]*funcxf.xfm[1][n-6] +
158 >                                fray->rop[2]*funcxf.xfm[2][n-6] +
159 >                                             funcxf.xfm[3][n-6] );
160  
161          if (n == 9) {                   /* distance */
162  
163                  sum = fray->rot;
164                  for (r = fray->parent; r != NULL; r = r->parent)
165                          sum += r->rot;
166 <                return(sum * fxf.sca);
166 >                return(sum * funcxf.sca);
167  
168          }
169          if (n == 10)                    /* dot product */
170                  return(fray->rod);
171  
172          if (n == 11)                    /* scale */
173 <                return(fxf.sca);
173 >                return(funcxf.sca);
174  
175          if (n < 15)                     /* origin */
176 <                return(fxf.xfm[3][n-12]);
176 >                return(funcxf.xfm[3][n-12]);
177  
178          if (n < 18)                     /* i unit vector */
179 <                return(fxf.xfm[0][n-15] / fxf.sca);
179 >                return(funcxf.xfm[0][n-15] / funcxf.sca);
180  
181          if (n < 21)                     /* j unit vector */
182 <                return(fxf.xfm[1][n-15] / fxf.sca);
182 >                return(funcxf.xfm[1][n-15] / funcxf.sca);
183  
184          if (n < 24)                     /* k unit vector */
185 <                return(fxf.xfm[2][n-21] / fxf.sca);
185 >                return(funcxf.xfm[2][n-21] / funcxf.sca);
186   badchan:
187          error(USER, "illegal channel number");
188   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines