--- ray/src/rt/t_func.c 2003/02/25 02:47:23 2.5 +++ ray/src/rt/t_func.c 2012/06/09 07:16:47 2.9 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: t_func.c,v 2.5 2003/02/25 02:47:23 greg Exp $"; +static const char RCSid[] = "$Id: t_func.c,v 2.9 2012/06/09 07:16:47 greg Exp $"; #endif /* * t_func.c - routine for procedural textures. @@ -8,8 +8,8 @@ static const char RCSid[] = "$Id: t_func.c,v 2.5 2003/ #include "copyright.h" #include "ray.h" - #include "func.h" +#include "rtotypes.h" /* * A procedural texture perturbs the surface normal @@ -28,9 +28,11 @@ static const char RCSid[] = "$Id: t_func.c,v 2.5 2003/ */ -t_func(m, r) /* compute texture for ray */ -register OBJREC *m; -register RAY *r; +extern int +t_func( /* compute texture for ray */ + register OBJREC *m, + register RAY *r +) { FVECT disp; double d; @@ -44,19 +46,18 @@ register RAY *r; errno = 0; for (i = 0; i < 3; i++) { disp[i] = evalue(mf->ep[i]); - if (errno) { + if (errno == EDOM || errno == ERANGE) { objerror(m, WARNING, "compute error"); return(0); } } - if (mf->f != &unitxf) - multv3(disp, disp, mf->f->xfm); + if (mf->fxp != &unitxf) + multv3(disp, disp, mf->fxp->xfm); if (r->rox != NULL) { multv3(disp, disp, r->rox->f.xfm); - d = 1.0 / (mf->f->sca * r->rox->f.sca); + d = 1.0 / (mf->fxp->sca * r->rox->f.sca); } else - d = 1.0 / mf->f->sca; - for (i = 0; i < 3; i++) - r->pert[i] += disp[i] * d; + d = 1.0 / mf->fxp->sca; + VSUM(r->pert, r->pert, disp, d); return(0); }