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 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

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: mx_func.c,v 2.7 2003/03/05 16:16:53 greg Exp $";
3 #endif
4 /*
5 * mx_func.c - routine for mixture functions.
6 */
7
8 #include "copyright.h"
9
10 #include "ray.h"
11 #include "func.h"
12 #include "rtotypes.h"
13
14 /*
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 extern int
30 mx_func( /* compute mixture function */
31 register OBJREC *m,
32 RAY *r
33 )
34 {
35 OBJECT obj;
36 register int i;
37 double coef;
38 OBJECT mod[2];
39 register MFUNC *mf;
40
41 if (m->oargs.nsargs < 4)
42 objerror(m, USER, "bad # arguments");
43 obj = objndx(m);
44 for (i = 0; i < 2; i++)
45 if (!strcmp(m->oargs.sarg[i], VOIDID))
46 mod[i] = OVOID;
47 else if ((mod[i] = lastmod(obj, m->oargs.sarg[i])) == OVOID) {
48 sprintf(errmsg, "undefined modifier \"%s\"",
49 m->oargs.sarg[i]);
50 objerror(m, USER, errmsg);
51 }
52 mf = getfunc(m, 3, 0x4, 0);
53 setfunc(m, r);
54 errno = 0;
55 coef = evalue(mf->ep[0]);
56 if (errno == EDOM || errno == ERANGE) {
57 objerror(m, WARNING, "compute error");
58 return(0);
59 }
60 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 }