1 |
– |
/* Copyright (c) 1988 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 |
|
* mx_func.c - routine for mixture functions. |
9 |
– |
* |
10 |
– |
* 11/2/88 |
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: |
26 |
|
*/ |
27 |
|
|
28 |
|
|
29 |
< |
mx_func(m, r) /* compute mixture function */ |
30 |
< |
register OBJREC *m; |
31 |
< |
RAY *r; |
29 |
> |
int |
30 |
> |
mx_func( /* compute mixture function */ |
31 |
> |
OBJREC *m, |
32 |
> |
RAY *r |
33 |
> |
) |
34 |
|
{ |
35 |
< |
extern double varvalue(); |
36 |
< |
extern int errno; |
36 |
< |
register int i; |
35 |
> |
OBJECT obj; |
36 |
> |
int i; |
37 |
|
double coef; |
38 |
|
OBJECT mod[2]; |
39 |
< |
register char **sa; |
39 |
> |
MFUNC *mf; |
40 |
|
|
41 |
– |
setfunc(m, r); |
42 |
– |
|
43 |
– |
sa = m->oargs.sarg; |
44 |
– |
|
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(sa[i], VOIDID)) |
45 |
> |
if (!strcmp(m->oargs.sarg[i], VOIDID)) |
46 |
|
mod[i] = OVOID; |
47 |
< |
else if ((mod[i] = modifier(sa[i])) == OVOID) { |
48 |
< |
sprintf(errmsg, "undefined modifier \"%s\"", sa[i]); |
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 |
< |
if (!vardefined(sa[2])) |
53 |
< |
loadfunc(sa[3]); |
52 |
> |
mf = getfunc(m, 3, 0x4, 0); |
53 |
> |
setfunc(m, r); |
54 |
|
errno = 0; |
55 |
< |
coef = varvalue(sa[2]); |
56 |
< |
if (errno) { |
55 |
> |
coef = evalue(mf->ep[0]); |
56 |
> |
if ((errno == EDOM) | (errno == ERANGE)) { |
57 |
|
objerror(m, WARNING, "compute error"); |
58 |
< |
return; |
58 |
> |
return(0); |
59 |
|
} |
60 |
< |
raymixture(r, mod[0], mod[1], coef); |
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 |
|
} |