--- ray/src/rt/func.c 1991/01/12 18:01:19 1.13 +++ ray/src/rt/func.c 1991/06/18 08:59:52 1.18 @@ -33,10 +33,13 @@ 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; + /* check to see if already set */ + if (m == fobj && r->rno == lastrno) + return(0); /* initialize if first call */ if (initfile != NULL) { loadfunc(initfile); @@ -48,13 +51,8 @@ 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; @@ -67,7 +65,9 @@ XF *bx; copystruct(&funcxf, &r->rox->b); else copystruct(&funcxf, bx); + lastrno = r->rno; eclock++; /* notify expression evaluator */ + return(1); } @@ -97,8 +97,7 @@ RAY *r; } m->os = (char *)mxf; } - setmap(m, r, mxf); - return; + return(setmap(m, r, mxf)); memerr: error(SYSTEM, "out of memory in setfunc"); } @@ -176,8 +175,10 @@ register int n; return(sum * funcxf.sca); } - if (n == 10) /* dot product */ - return(fray->rod); + if (n == 10) /* dot product (range [-1,1]) */ + return( fray->rod <= -1.0 ? -1.0 : + fray->rod >= 1.0 ? 1.0 : + fray->rod ); if (n == 11) /* scale */ return(funcxf.sca);