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.26 by greg, Sat Jun 9 07:16:47 2012 UTC vs.
Revision 2.30 by greg, Wed May 20 13:16:20 2015 UTC

# Line 11 | Line 11 | static const char      RCSid[] = "$Id$";
11   #include  "paths.h"
12   #include  "otypes.h"
13   #include  "func.h"
14 + #include <ctype.h>
15  
16  
17   #define  INITFILE       "rayinit.cal"
# Line 62 | Line 63 | initfunc()     /* initialize function evaluation */
63   }
64  
65  
66 + /* Set parameters for current evaluation */
67 + void
68 + set_eparams(char *prms)
69 + {
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 == last_params))
76 +                return;
77 +        if (last_params != NULL && !strcmp(prms, last_params))
78 +                return;
79 +        last_params = prms;             /* assign each variable */
80 +        while (*prms) {
81 +                if (isspace(*prms)) {
82 +                        ++prms; continue;
83 +                }
84 +                if (!isalpha(*prms))
85 +                        goto bad_params;
86 +                cpd = vname;
87 +                while (*prms && (*prms != '=') & !isspace(*prms)) {
88 +                        if (!isid(*prms))
89 +                                goto bad_params;
90 +                        *cpd++ = *prms++;
91 +                }
92 +                if (cpd == vname)
93 +                        goto bad_params;
94 +                *cpd = '\0';
95 +                while (isspace(*prms)) prms++;
96 +                if (*prms++ != '=')
97 +                        goto bad_params;
98 +                value = atof(prms);
99 +                if ((prms = fskip(prms)) == NULL)
100 +                        goto bad_params;
101 +                while (isspace(*prms)) prms++;
102 +                prms += (*prms == ',') | (*prms == ';');
103 +                varset(vname, '=', value);
104 +        }
105 +        return;
106 + bad_params:
107 +        sprintf(errmsg, "bad parameter list '%s'", last_params);
108 +        error(USER, errmsg);
109 + }
110 +
111 +
112   MFUNC *
113   getfunc(        /* get function for this modifier */
114          OBJREC  *m,
# Line 213 | Line 260 | worldfunc(                     /* special function context sans object *
260   )
261   {
262          static RNUMBER  lastrno = ~0;
263 +
264 +        if (rayinitcal[0])              /* initialize on first call */
265 +                initfunc();
266                                          /* set evaluator context */
267          setcontext(ctx);
268                                          /* check if ray already set */
# Line 302 | Line 352 | chanvalue(                     /* return channel n to calcomp */
352                                  fray->ron[2]*funcxf.xfm[2][n-3] )
353                           / funcxf.sca );
354  
355 <        if (n <= 8)                     /* intersection */
355 >        if (n <= 8) {                   /* intersection point */
356 >                if (fray->rot >= FHUGE)
357 >                        return(0.0);    /* XXX should be runtime error? */
358  
359                  return( fray->rop[0]*funcxf.xfm[0][n-6] +
360                                  fray->rop[1]*funcxf.xfm[1][n-6] +
361                                  fray->rop[2]*funcxf.xfm[2][n-6] +
362                                               funcxf.xfm[3][n-6] );
363 +        }
364  
365          if (n == 9)                     /* total distance */
366                  return(raydist(fray,PRIMARY) * funcxf.sca);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines