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.33 by greg, Sat May 13 00:09:53 2017 UTC vs.
Revision 2.39 by greg, Wed Mar 30 16:00:56 2022 UTC

# Line 43 | Line 43 | initfunc(void) /* initialize function evaluation */
43                  return;
44          esupport |= E_VARIABLE|E_FUNCTION|E_INCHAN|E_RCONST|E_REDEFW;
45          esupport &= ~(E_OUTCHAN);
46 <        setcontext("");
46 >        calcontext("");
47          scompile("Dx=$1;Dy=$2;Dz=$3;", NULL, 0);
48          scompile("Nx=$4;Ny=$5;Nz=$6;", NULL, 0);
49          scompile("Px=$7;Py=$8;Pz=$9;", NULL, 0);
# Line 67 | Line 67 | initfunc(void) /* initialize function evaluation */
67   void
68   set_eparams(char *prms)
69   {
70 <        static char     *last_params;
71 <        static int      lplen = 0;
72 <        int             len;
70 >        static char     *last_params = NULL;
71          char            vname[RMAXWORD];
72          double          value;
73          char            *cpd;
74                                          /* check if already set */
75          if (prms == NULL || !*prms)
76                  return;
77 <        if (lplen && !strcmp(prms, last_params))
77 >        if (prms == last_params || (last_params != NULL &&
78 >                                        !strcmp(prms, last_params)))
79                  return;
80 <        len = strlen(prms);             /* record new settings */
82 <        if ((lplen != 0) & (lplen <= len)) {
83 <                free(last_params);
84 <                lplen = 0;
85 <        }
86 <        if (!lplen) {
87 <                lplen = len + 100;
88 <                last_params = (char *)malloc(lplen);
89 <                if (last_params == NULL)
90 <                        error(SYSTEM, "out of memory in set_eparams()");
91 <        }
92 <        strcpy(last_params, prms);
80 >        last_params = prms;             /* XXX assumes static string */
81                                          /* assign each variable */
82          while (*prms) {
83                  if (isspace(*prms)) {
# Line 111 | Line 99 | set_eparams(char *prms)
99                  if ((prms = fskip(prms)) == NULL)
100                          goto bad_params;
101                  while (isspace(*prms)) prms++;
102 <                prms += (*prms == ',') | (*prms == ';');
102 >                prms += (*prms == ',') | (*prms == ';') | (*prms == ':');
103                  varset(vname, '=', value);
104          }
105 +        eclock++;               /* notify expression evaluator */
106          return;
107   bad_params:
108          sprintf(errmsg, "bad parameter list '%s'", last_params);
# Line 147 | Line 136 | getfunc(       /* get function for this modifier */
136                  goto memerr;
137          i = strlen(arg[ff]);                    /* set up context */
138          if (i == 1 && arg[ff][0] == '.') {
139 <                setcontext(f->ctx = "");        /* "." means no file */
139 >                calcontext(f->ctx = "");        /* "." means no file */
140          } else {
141                  strcpy(sbuf,arg[ff]);           /* file name is context */
142                  if (i > LCALSUF && !strcmp(sbuf+i-LCALSUF, CALSUF))
143                          sbuf[i-LCALSUF] = '\0'; /* remove suffix */
144 <                setcontext(f->ctx = savestr(sbuf));
144 >                calcontext(f->ctx = savestr(sbuf));
145                  if (!vardefined(REFVNAME)) {    /* file loaded? */
146                          loadfunc(arg[ff]);
147                          varset(REFVNAME, '=', 1.0);
# Line 216 | Line 205 | freefunc(                      /* free memory associated with modifier */
205          for (i = 0; f->ep[i] != NULL; i++)
206                  epfree(f->ep[i]);
207          if (f->ctx[0]) {                        /* done with definitions */
208 <                setcontext(f->ctx);
208 >                calcontext(f->ctx);
209                  i = varvalue(REFVNAME)-.5;      /* reference_count-- */
210                  if (i > 0)
211                          varset(REFVNAME, '=', (double)i);
# Line 245 | Line 234 | setfunc(                       /* set channels for function call */
234          if ((f = (MFUNC *)m->os) == NULL)
235                  objerror(m, CONSISTENCY, "setfunc called before getfunc");
236                  
237 <        setcontext(f->ctx);             /* set evaluator context */
237 >        calcontext(f->ctx);             /* set evaluator context */
238                                          /* check to see if matrix set */
239          if ((m == fobj) & (r->rno == lastrno))
240                  return(0);
# Line 276 | Line 265 | worldfunc(                     /* special function context sans object *
265          if (rayinitcal[0])              /* initialize on first call */
266                  initfunc();
267                                          /* set evaluator context */
268 <        setcontext(ctx);
268 >        calcontext(ctx);
269                                          /* check if ray already set */
270          if ((fobj == NULL) & (r->rno == lastrno))
271                  return(0);
# Line 310 | Line 299 | l_arg(char *nm)                        /* return nth real argument */
299          int  n;
300  
301          if (fobj == NULL)
302 <                error(INTERNAL, "arg(n) called without a modifier context");
302 >                error(USER,
303 >                        "bad call to arg(n) - illegal constant in .cal file?");
304  
305          n = argument(1) + .5;           /* round to integer */
306  
# Line 365 | Line 355 | chanvalue(                     /* return channel n to calcomp */
355                           / funcxf.sca );
356  
357          if (n <= 8) {                   /* intersection point */
358 <                if (fray->rot >= FHUGE)
358 >                if (fray->rot >= FHUGE*.99)
359                          return(0.0);    /* XXX should be runtime error? */
360  
361                  return( fray->rop[0]*funcxf.xfm[0][n-6] +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines