ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/mx_func.c
Revision: 2.4
Committed: Mon Aug 10 18:35:14 1998 UTC (25 years, 8 months ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 2.3: +5 -3 lines
Log Message:
changed modifier checking to take most recent definition

File Contents

# User Rev Content
1 gwlarson 2.4 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2 greg 1.1
3     #ifndef lint
4 gwlarson 2.4 static char SCCSid[] = "$SunId$ SGI";
5 greg 1.1 #endif
6    
7     /*
8     * mx_func.c - routine for mixture functions.
9     *
10     * 11/2/88
11     */
12    
13     #include "ray.h"
14    
15 greg 2.2 #include "func.h"
16    
17 greg 1.1 /*
18     * A mixture function is specified:
19     *
20     * modifier mixfunc name
21     * 4+ foremod backmod varname vfname xf
22     * 0
23     * n A1 A2 ..
24     *
25     * Vfname is the name of the file where the variable definition
26     * can be found. The list of real arguments can be accessed by
27     * definitions in the file. The xf is a transformation
28     * to get from the original coordinates to the current coordinates.
29     */
30    
31    
32     mx_func(m, r) /* compute mixture function */
33     register OBJREC *m;
34     RAY *r;
35     {
36 gwlarson 2.4 OBJECT obj;
37 greg 1.1 register int i;
38     double coef;
39     OBJECT mod[2];
40 greg 2.2 register MFUNC *mf;
41 greg 1.1
42     if (m->oargs.nsargs < 4)
43     objerror(m, USER, "bad # arguments");
44 gwlarson 2.4 obj = objndx(m);
45 greg 1.1 for (i = 0; i < 2; i++)
46 greg 2.2 if (!strcmp(m->oargs.sarg[i], VOIDID))
47 greg 1.1 mod[i] = OVOID;
48 gwlarson 2.4 else if ((mod[i] = lastmod(obj, m->oargs.sarg[i])) == OVOID) {
49 greg 2.2 sprintf(errmsg, "undefined modifier \"%s\"",
50     m->oargs.sarg[i]);
51 greg 1.1 objerror(m, USER, errmsg);
52     }
53 greg 2.2 mf = getfunc(m, 3, 0x4, 0);
54     setfunc(m, r);
55 greg 1.1 errno = 0;
56 greg 2.2 coef = evalue(mf->ep[0]);
57 greg 1.1 if (errno) {
58     objerror(m, WARNING, "compute error");
59 greg 2.3 return(0);
60 greg 1.1 }
61 greg 2.3 if (raymixture(r, mod[0], mod[1], coef)) {
62     if (m->omod != OVOID)
63     objerror(m, USER, "inappropriate modifier");
64     return(1);
65     }
66     return(0);
67 greg 1.1 }