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 2.3 by greg, Tue Dec 24 17:43:43 1991 UTC vs.
Revision 2.8 by greg, Mon Mar 8 12:37:23 1993 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 23 | Line 23 | static char SCCSid[] = "$SunId$ LBL";
23   #define  LCALSUF        4
24  
25   XF  unitxf = {                  /* identity transform */
26 <        1.0, 0.0, 0.0, 0.0,
27 <        0.0, 1.0, 0.0, 0.0,
28 <        0.0, 0.0, 1.0, 0.0,
29 <        0.0, 0.0, 0.0, 1.0,
26 >        {{1.0, 0.0, 0.0, 0.0},
27 >        {0.0, 1.0, 0.0, 0.0},
28 >        {0.0, 0.0, 1.0, 0.0},
29 >        {0.0, 0.0, 0.0, 1.0}},
30          1.0
31   };
32  
# Line 54 | Line 54 | int  dofwd;
54                                          /* check to see if done already */
55          if ((f = (MFUNC *)m->os) != NULL)
56                  return(f);
57 +        fobj = NULL; fray = NULL;
58          if (initfile[0]) {              /* initialize on first call */
59                  setcontext("");
60                  scompile("Dx=$1;Dy=$2;Dz=$3;", NULL, 0);
61                  scompile("Nx=$4;Ny=$5;Nz=$6;", NULL, 0);
62                  scompile("Px=$7;Py=$8;Pz=$9;", NULL, 0);
63 <                scompile("T=$10;Rdot=$11;", NULL, 0);
63 >                scompile("T=$10;Ts=$25;Rdot=$11;", NULL, 0);
64                  scompile("S=$12;Tx=$13;Ty=$14;Tz=$15;", NULL, 0);
65                  scompile("Ix=$16;Iy=$17;Iz=$18;", NULL, 0);
66                  scompile("Jx=$19;Jy=$20;Jz=$21;", NULL, 0);
# Line 80 | Line 81 | int  dofwd;
81          if (i == 1 && arg[ff][0] == '.')
82                  setcontext(f->ctx = "");        /* "." means no file */
83          else {
84 <                strcpy(sbuf,m->oargs.sarg[ff]); /* file name is context */
84 >                strcpy(sbuf,arg[ff]);   /* file name is context */
85                  if (i > LCALSUF && !strcmp(sbuf+i-LCALSUF, CALSUF))
86                          sbuf[i-LCALSUF] = '\0'; /* remove suffix */
87                  setcontext(f->ctx = savestr(sbuf));
88                  if (!vardefined(REFVNAME)) {    /* file loaded? */
89 <                        loadfunc(m->oargs.sarg[ff]);
89 >                        loadfunc(arg[ff]);
90                          varset(REFVNAME, '=', 1.0);
91                  } else                          /* reference_count++ */
92                          varset(REFVNAME, '=', varvalue(REFVNAME)+1.0);
# Line 127 | Line 128 | int  dofwd;
128          m->os = (char *)f;
129          return(f);
130   toofew:
131 <        objerror(m, USER, "too few arguments");
131 >        objerror(m, USER, "too few string arguments");
132   memerr:
133          error(SYSTEM, "out of memory in getfunc");
134   }
# Line 211 | Line 212 | l_arg()                                /* return nth real argument */
212          extern double  argument();
213          register int  n;
214  
215 +        if (fobj == NULL)
216 +                syntax("arg(n) used in constant expression");
217 +
218          n = argument(1) + .5;           /* round to integer */
219  
220          if (n < 1)
# Line 249 | Line 253 | register int  n;
253          double  sum;
254          register RAY  *r;
255  
256 +        if (fray == NULL)
257 +                syntax("ray parameter used in constant expression");
258 +
259          if (--n < 0)
260                  goto badchan;
261  
# Line 273 | Line 280 | register int  n;
280                                  fray->rop[2]*funcxf.xfm[2][n-6] +
281                                               funcxf.xfm[3][n-6] );
282  
283 <        if (n == 9) {                   /* distance */
277 <
283 >        if (n == 9) {                   /* total distance */
284                  sum = fray->rot;
285                  for (r = fray->parent; r != NULL; r = r->parent)
286                          sum += r->rot;
287                  return(sum * funcxf.sca);
288  
289          }
290 +
291          if (n == 10)                    /* dot product (range [-1,1]) */
292                  return( fray->rod <= -1.0 ? -1.0 :
293                          fray->rod >= 1.0 ? 1.0 :
# Line 300 | Line 307 | register int  n;
307  
308          if (n < 24)                     /* k unit vector */
309                  return(funcxf.xfm[2][n-21] / funcxf.sca);
310 +
311 +        if (n == 24) {                  /* single ray (shadow) distance */
312 +                sum = fray->rot;
313 +                for (r = fray->parent; r != NULL && r->crtype&SHADOW;
314 +                                r = r->parent)
315 +                        sum += r->rot;
316 +                return(sum * funcxf.sca);
317 +        }
318   badchan:
319          error(USER, "illegal channel number");
320   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines