--- ray/src/rt/p_func.c 1989/02/02 10:41:34 1.1 +++ ray/src/rt/p_func.c 2014/07/08 18:25:00 2.8 @@ -1,16 +1,15 @@ -/* Copyright (c) 1986 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: p_func.c,v 2.8 2014/07/08 18:25:00 greg Exp $"; #endif - /* * p_func.c - routine for procedural patterns. - * - * 4/8/86 */ +#include "copyright.h" + #include "ray.h" +#include "func.h" +#include "rtotypes.h" /* * A procedural pattern can either be a brightness or a @@ -35,57 +34,51 @@ static char SCCSid[] = "$SunId$ LBL"; */ -p_bfunc(m, r) /* compute brightness pattern */ -register OBJREC *m; -RAY *r; +int +p_bfunc( /* compute brightness pattern */ + OBJREC *m, + RAY *r +) { - extern double varvalue(); - extern int errno; double bval; - register char **sa; + MFUNC *mf; - setfunc(m, r); - - sa = m->oargs.sarg; - if (m->oargs.nsargs < 2) objerror(m, USER, "bad # arguments"); - if (!vardefined(sa[0])) - loadfunc(sa[1]); + mf = getfunc(m, 1, 0x1, 0); + setfunc(m, r); errno = 0; - bval = varvalue(sa[0]); - if (errno) { + bval = evalue(mf->ep[0]); + if (errno == EDOM || errno == ERANGE) { objerror(m, WARNING, "compute error"); - return; + return(0); } scalecolor(r->pcol, bval); + return(0); } -p_cfunc(m, r) /* compute color pattern */ -register OBJREC *m; -RAY *r; +int +p_cfunc( /* compute color pattern */ + OBJREC *m, + RAY *r +) { - extern double varvalue(); - extern int errno; COLOR cval; - register char **sa; + MFUNC *mf; - setfunc(m, r); - - sa = m->oargs.sarg; - if (m->oargs.nsargs < 4) objerror(m, USER, "bad # arguments"); - if (!vardefined(sa[0])) - loadfunc(sa[3]); + mf = getfunc(m, 3, 0x7, 0); + setfunc(m, r); errno = 0; - setcolor(cval, varvalue(sa[0]), - varvalue(sa[1]), - varvalue(sa[2])); - if (errno) { + setcolor(cval, evalue(mf->ep[0]), + evalue(mf->ep[1]), + evalue(mf->ep[2])); + if (errno == EDOM || errno == ERANGE) { objerror(m, WARNING, "compute error"); - return; + return(0); } multcolor(r->pcol, cval); + return(0); }