ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/mx_func.c
Revision: 2.8
Committed: Tue Mar 30 16:13:01 2004 UTC (20 years, 1 month ago) by schorsch
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1, rad4R1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9
Changes since 2.7: +7 -5 lines
Log Message:
Continued ANSIfication. There are only bits and pieces left now.

File Contents

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