--- ray/src/rt/func.c 1990/04/07 16:12:56 1.8 +++ ray/src/rt/func.c 1990/08/04 11:47:46 1.10 @@ -38,14 +38,14 @@ double sca; if (initfile != NULL) { loadfunc(initfile); - scompile(NULL, "Dx=$1;Dy=$2;Dz=$3;"); - scompile(NULL, "Nx=$4;Ny=$5;Nz=$6;"); - scompile(NULL, "Px=$7;Py=$8;Pz=$9;"); - scompile(NULL, "T=$10;Rdot=$11;"); - scompile(NULL, "S=$12;Tx=$13;Ty=$14;Tz=$15;"); - scompile(NULL, "Ix=$16;Iy=$17;Iz=$18;"); - scompile(NULL, "Jx=$19;Jy=$20;Jz=$21;"); - scompile(NULL, "Kx=$22;Ky=$23;Kz=$24;"); + scompile("Dx=$1;Dy=$2;Dz=$3;", NULL, 0); + scompile("Nx=$4;Ny=$5;Nz=$6;", NULL, 0); + scompile("Px=$7;Py=$8;Pz=$9;", NULL, 0); + scompile("T=$10;Rdot=$11;", NULL, 0); + scompile("S=$12;Tx=$13;Ty=$14;Tz=$15;", NULL, 0); + 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); @@ -133,22 +133,9 @@ register int n; double sum; register RAY *r; - n--; /* for convenience */ + if (--n < 0) + goto badchan; - if (n < 0 || n > 23) - error(USER, "illegal channel number"); - - if (n == 9) { /* distance */ - - sum = fray->rot; - for (r = fray->parent; r != NULL; r = r->parent) - sum += r->rot; - return(sum * fxf.sca); - - } - if (n == 10) /* dot product */ - return(fray->rod); - if (n < 3) /* ray direction */ return( ( fray->rdir[0]*fxf.xfm[0][n] + @@ -170,6 +157,17 @@ register int n; fray->rop[2]*fxf.xfm[2][n-6] + fxf.xfm[3][n-6] ); + if (n == 9) { /* distance */ + + sum = fray->rot; + for (r = fray->parent; r != NULL; r = r->parent) + sum += r->rot; + return(sum * fxf.sca); + + } + if (n == 10) /* dot product */ + return(fray->rod); + if (n == 11) /* scale */ return(fxf.sca); @@ -184,4 +182,6 @@ register int n; if (n < 24) /* k unit vector */ return(fxf.xfm[2][n-21] / fxf.sca); +badchan: + error(USER, "illegal channel number"); }