--- ray/src/rt/func.c 1990/12/15 15:03:26 1.12 +++ ray/src/rt/func.c 1991/06/17 08:28:26 1.16 @@ -1,4 +1,4 @@ -/* Copyright (c) 1990 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -15,6 +15,14 @@ static char SCCSid[] = "$SunId$ LBL"; #include "otypes.h" +XF unitxf = { /* identity transform */ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0, + 1.0 +}; + XF funcxf; /* current transformation */ static OBJREC *fobj = NULL; /* current function object */ static RAY *fray = NULL; /* current function ray */ @@ -25,8 +33,7 @@ OBJREC *m; register RAY *r; XF *bx; { - extern double l_noise3(), l_noise3a(), l_noise3b(), l_noise3c(); - extern double l_hermite(), l_fnoise3(), l_arg(); + extern double l_arg(); extern long eclock; static char *initfile = "rayinit.cal"; static long lastrno = -1; @@ -44,23 +51,21 @@ XF *bx; scompile("Ix=$16;Iy=$17;Iz=$18;", NULL, 0); scompile("Jx=$19;Jy=$20;Jz=$21;", NULL, 0); scompile("Kx=$22;Ky=$23;Kz=$24;", NULL, 0); - funset("arg", 1, l_arg); - funset("noise3", 3, l_noise3); - funset("noise3a", 3, l_noise3a); - funset("noise3b", 3, l_noise3b); - funset("noise3c", 3, l_noise3c); - funset("hermite", 5, l_hermite); - funset("fnoise3", 3, l_fnoise3); + funset("arg", 1, '=', l_arg); + setnoisefuncs(); initfile = NULL; } fobj = m; fray = r; - lastrno = r->rno; - if (r->rox != NULL) { - funcxf.sca = r->rox->b.sca * bx->sca; - multmat4(funcxf.xfm, r->rox->b.xfm, bx->xfm); - } else + if (r->rox != NULL) + if (bx != &unitxf) { + funcxf.sca = r->rox->b.sca * bx->sca; + multmat4(funcxf.xfm, r->rox->b.xfm, bx->xfm); + } else + copystruct(&funcxf, &r->rox->b); + else copystruct(&funcxf, bx); + lastrno = r->rno; eclock++; /* notify expression evaluator */ } @@ -78,13 +83,17 @@ RAY *r; for (n = m->oargs.nsargs, sa = m->oargs.sarg; n > 0 && **sa != '-'; n--, sa++) ; - mxf = (XF *)malloc(sizeof(XF)); - if (mxf == NULL) - goto memerr; - if (invxf(mxf, n, sa) != n) - objerror(m, USER, "bad transform"); - if (mxf->sca < 0.0) - mxf->sca = -mxf->sca; + if (n == 0) + mxf = &unitxf; + else { + mxf = (XF *)malloc(sizeof(XF)); + if (mxf == NULL) + goto memerr; + if (invxf(mxf, n, sa) != n) + objerror(m, USER, "bad transform"); + if (mxf->sca < 0.0) + mxf->sca = -mxf->sca; + } m->os = (char *)mxf; } setmap(m, r, mxf);