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.6 by greg, Wed Apr 19 21:20:29 1989 UTC vs.
Revision 2.6 by greg, Wed Mar 5 16:16:53 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1986 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 28 | Line 27 | static char SCCSid[] = "$SunId$ LBL";
27   *  from the original coordinates to the current coordinates.
28   */
29  
31 typedef struct {
32        struct {
33                double  sca;            /* scale factor */
34                double  xfm[4][4];      /* transformation matrix */
35        }  fore, back;
36 }  XFORM;
30  
38
31   t_func(m, r)                    /* compute texture for ray */
32   register OBJREC  *m;
33   register RAY  *r;
34   {
43        extern double  varvalue();
44        extern int  errno;
35          FVECT  disp;
36          double  d;
37 <        register XFORM  *mxf;
37 >        register MFUNC  *mf;
38          register int  i;
49        register char  **sa;
39  
40          if (m->oargs.nsargs < 4)
41                  objerror(m, USER, "bad # arguments");
42 <        sa = m->oargs.sarg;
43 <
55 <        if ((mxf = (XFORM *)m->os) == NULL) {
56 <                mxf = (XFORM *)malloc(sizeof(XFORM));
57 <                if (mxf == NULL)
58 <                        goto memerr;
59 <                mxf->fore.sca = 1.0;
60 <                setident4(mxf->fore.xfm);
61 <                if (xf(mxf->fore.xfm, &mxf->fore.sca,
62 <                        m->oargs.nsargs-4, sa+4) != m->oargs.nsargs-4)
63 <                        objerror(m, USER, "bad transform");
64 <                if (mxf->fore.sca < 0.0)
65 <                        mxf->fore.sca = -mxf->fore.sca;
66 <                mxf->back.sca = 1.0;
67 <                setident4(mxf->back.xfm);
68 <                invxf(mxf->back.xfm, &mxf->back.sca,
69 <                                m->oargs.nsargs-4, sa+4);
70 <                if (mxf->back.sca < 0.0)
71 <                        mxf->back.sca = -mxf->back.sca;
72 <                m->os = (char *)mxf;
73 <        }
74 <
75 <        setmap(m, r, mxf->back.xfm, mxf->back.sca);
76 <
77 <        if (!vardefined(sa[0]))
78 <                loadfunc(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->fore.xfm);
53 <        multv3(disp, disp, r->rofx);
54 <        d = 1.0 / (mxf->fore.sca * r->rofs);
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 / (mf->f->sca * r->rox->f.sca);
57 >        } else
58 >                d = 1.0 / mf->f->sca;
59          for (i = 0; i < 3; i++)
60                  r->pert[i] += disp[i] * d;
61 <        return;
92 < memerr:
93 <        error(SYSTEM, "out of memory in t_func");
61 >        return(0);
62   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines