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.5 by greg, Tue Apr 11 13:30:33 1989 UTC vs.
Revision 2.2 by greg, Mon Nov 25 09:50:59 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include  "ray.h"
14  
15 + #include  "func.h"
16 +
17   /*
18   *      A procedural texture perturbs the surface normal
19   *  at the point of intersection with an object.  It has
# Line 28 | Line 30 | static char SCCSid[] = "$SunId$ LBL";
30   *  from the original coordinates to the current coordinates.
31   */
32  
31 typedef struct {
32        struct {
33                double  sca;            /* scale factor */
34                double  xfm[4][4];      /* transformation matrix */
35        }  fore, back;
36 }  XFORM;
33  
38
34   t_func(m, r)                    /* compute texture for ray */
35   register OBJREC  *m;
36   register RAY  *r;
37   {
43        extern double  varvalue();
44        extern int  errno;
38          FVECT  disp;
39 <        register XFORM  *mxf;
39 >        double  d;
40 >        register MFUNC  *mf;
41          register int  i;
48        register char  **sa;
42  
43          if (m->oargs.nsargs < 4)
44                  objerror(m, USER, "bad # arguments");
45 <        sa = m->oargs.sarg;
46 <
54 <        if ((mxf = (XFORM *)m->os) == NULL) {
55 <                mxf = (XFORM *)malloc(sizeof(XFORM));
56 <                if (mxf == NULL)
57 <                        goto memerr;
58 <                mxf->fore.sca = 1.0;
59 <                setident4(mxf->fore.xfm);
60 <                if (xf(mxf->fore.xfm, &mxf->fore.sca,
61 <                        m->oargs.nsargs-4, sa+4) != m->oargs.nsargs-4)
62 <                        objerror(m, USER, "bad transform");
63 <                if (mxf->fore.sca < 0.0)
64 <                        mxf->fore.sca = -mxf->fore.sca;
65 <                mxf->back.sca = 1.0;
66 <                setident4(mxf->back.xfm);
67 <                invxf(mxf->back.xfm, &mxf->back.sca,
68 <                                m->oargs.nsargs-4, sa+4);
69 <                if (mxf->back.sca < 0.0)
70 <                        mxf->back.sca = -mxf->back.sca;
71 <                m->os = (char *)mxf;
72 <        }
73 <
74 <        setmap(m, r, mxf->back.xfm, mxf->back.sca);
75 <
76 <        if (!vardefined(sa[0]))
77 <                loadfunc(sa[3]);
45 >        mf = getfunc(m, 3, 0x7, 1);
46 >        setfunc(m, r);
47          errno = 0;
48 <        for (i = 0; i < 3; i++)
49 <                disp[i] = varvalue(sa[i]);
50 <        if (errno) {
51 <                objerror(m, WARNING, "compute error");
52 <                return;
48 >        for (i = 0; i < 3; i++) {
49 >                disp[i] = evalue(mf->ep[i]);
50 >                if (errno) {
51 >                        objerror(m, WARNING, "compute error");
52 >                        return;
53 >                }
54          }
55 <        multv3(disp, disp, mxf->fore.xfm);
56 <        multv3(disp, disp, r->rofx);
55 >        if (mf->f != &unitxf)
56 >                multv3(disp, disp, mf->f->xfm);
57 >        if (r->rox != NULL) {
58 >                multv3(disp, disp, r->rox->f.xfm);
59 >                d = 1.0 / (mf->f->sca * r->rox->f.sca);
60 >        } else
61 >                d = 1.0 / mf->f->sca;
62          for (i = 0; i < 3; i++)
63 <                r->pert[i] += disp[i] / (mxf->fore.sca * r->rofs);
89 <        return;
90 < memerr:
91 <        error(SYSTEM, "out of memory in t_func");
63 >                r->pert[i] += disp[i] * d;
64   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines