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

Comparing ray/src/rt/t_func.c (file contents):
Revision 1.9 by greg, Thu Aug 8 11:29:51 1991 UTC vs.
Revision 2.6 by greg, Wed Mar 5 16:16:53 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1990 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   *  t_func.c - routine for procedural textures.
9 *
10 *     4/8/86
6   */
7  
8 + #include "copyright.h"
9 +
10   #include  "ray.h"
11  
12 + #include  "func.h"
13 +
14   /*
15   *      A procedural texture perturbs the surface normal
16   *  at the point of intersection with an object.  It has
# Line 33 | Line 32 | t_func(m, r)                   /* compute texture for ray */
32   register OBJREC  *m;
33   register RAY  *r;
34   {
36        extern double  varvalue();
37        extern int  errno;
35          FVECT  disp;
36          double  d;
37 <        register FULLXF  *mxf;
37 >        register MFUNC  *mf;
38          register int  i;
42        register char  **sa;
39  
40          if (m->oargs.nsargs < 4)
41                  objerror(m, USER, "bad # arguments");
42 <        sa = m->oargs.sarg;
43 <
48 <        if ((mxf = (FULLXF *)m->os) == NULL) {
49 <                mxf = (FULLXF *)malloc(sizeof(FULLXF));
50 <                if (mxf == NULL)
51 <                        goto memerr;
52 <                if (fullxf(mxf, m->oargs.nsargs-4, sa+4) != m->oargs.nsargs-4)
53 <                        objerror(m, USER, "bad transform");
54 <                if (mxf->f.sca < 0.0)
55 <                        mxf->f.sca = -mxf->f.sca;
56 <                if (mxf->b.sca < 0.0)
57 <                        mxf->b.sca = -mxf->b.sca;
58 <                m->os = (char *)mxf;
59 <        }
60 <
61 <        setmap(m, r, &mxf->b);
62 <
63 <        funcfile(sa[3]);
42 >        mf = getfunc(m, 3, 0x7, 1);
43 >        setfunc(m, r);
44          errno = 0;
45 <        for (i = 0; i < 3; i++)
46 <                disp[i] = varvalue(sa[i]);
47 <        if (errno) {
48 <                objerror(m, WARNING, "compute error");
49 <                return;
45 >        for (i = 0; i < 3; i++) {
46 >                disp[i] = evalue(mf->ep[i]);
47 >                if (errno == EDOM || errno == ERANGE) {
48 >                        objerror(m, WARNING, "compute error");
49 >                        return(0);
50 >                }
51          }
52 <        multv3(disp, disp, mxf->f.xfm);
52 >        if (mf->f != &unitxf)
53 >                multv3(disp, disp, mf->f->xfm);
54          if (r->rox != NULL) {
55                  multv3(disp, disp, r->rox->f.xfm);
56 <                d = 1.0 / (mxf->f.sca * r->rox->f.sca);
56 >                d = 1.0 / (mf->f->sca * r->rox->f.sca);
57          } else
58 <                d = 1.0 / mxf->f.sca;
58 >                d = 1.0 / mf->f->sca;
59          for (i = 0; i < 3; i++)
60                  r->pert[i] += disp[i] * d;
61 <        return;
80 < memerr:
81 <        error(SYSTEM, "out of memory in t_func");
61 >        return(0);
62   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines