--- ray/src/hd/holo.c 1999/03/12 09:37:47 3.16 +++ ray/src/hd/holo.c 2004/01/01 11:21:55 3.21 @@ -1,9 +1,6 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: holo.c,v 3.21 2004/01/01 11:21:55 schorsch Exp $"; #endif - /* * Routines for converting holodeck coordinates, etc. * @@ -20,8 +17,10 @@ int hdwg1[6] = {2,2,0,0,1,1}; static double logstep; -hdcompgrid(hp) /* compute derived grid vector and index */ -register HOLO *hp; +extern void +hdcompgrid( /* compute derived grid vector and index */ + register HOLO *hp +) { double d; register int i, j; @@ -38,7 +37,7 @@ register HOLO *hp; for (i = 0; i < 3; i++) { fcross(hp->wg[i], hp->xv[(i+1)%3], hp->xv[(i+2)%3]); d = DOT(hp->wg[i],hp->xv[i]); - if (d <= FTINY & d >= -FTINY) + if ((d <= FTINY) & (d >= -FTINY)) error(USER, "degenerate holodeck section"); d = hp->grid[i] / d; hp->wg[i][0] *= d; hp->wg[i][1] *= d; hp->wg[i][2] *= d; @@ -57,18 +56,20 @@ register HOLO *hp; } -hdbcoord(gc, hp, i) /* compute beam coordinates from index */ -GCOORD gc[2]; /* returned */ -register HOLO *hp; -register int i; +extern int +hdbcoord( /* compute beam coordinates from index */ + GCOORD gc[2], /* returned */ + register HOLO *hp, + register int i +) { register int j, n; int n2, reverse; GCOORD g2[2]; /* check range */ - if (i < 1 | i > nbeams(hp)) + if ((i < 1) | (i > nbeams(hp))) return(0); - if (reverse = i >= hp->wi[5]) + if ( (reverse = i >= hp->wi[5]) ) i -= hp->wi[5] - 1; for (j = 0; j < 5; j++) /* find w0 */ if (hp->wi[j+1] > i) @@ -93,30 +94,31 @@ register int i; gc[1].i[1] = i / hp->grid[hdwg0[gc[1].w]]; gc[1].i[0] = i - gc[1].i[1]*hp->grid[hdwg0[gc[1].w]]; if (reverse) { - copystruct(g2, gc+1); - copystruct(gc+1, gc); - copystruct(gc, g2); + *g2 = *(gc+1); + *(gc+1) = *gc; + *gc = *g2; } return(1); /* we're done */ } -int -hdbindex(hp, gc) /* compute index from beam coordinates */ -register HOLO *hp; -register GCOORD gc[2]; +extern int +hdbindex( /* compute index from beam coordinates */ + register HOLO *hp, + register GCOORD gc[2] +) { GCOORD g2[2]; int reverse; register int i, j; /* check ordering and limits */ - if (reverse = gc[0].w > gc[1].w) { - copystruct(g2, gc+1); - copystruct(g2+1, gc); + if ( (reverse = gc[0].w > gc[1].w) ) { + *g2 = *(gc+1); + *(g2+1) = *gc; gc = g2; } else if (gc[0].w == gc[1].w) return(0); - if (gc[0].w < 0 | gc[1].w > 5) + if ((gc[0].w < 0) | (gc[1].w > 5)) return(0); i = 0; /* compute index */ for (j = gc[0].w+1; j < gc[1].w; j++) @@ -132,12 +134,14 @@ register GCOORD gc[2]; } -hdcell(cp, hp, gc) /* compute cell coordinates */ -register FVECT cp[4]; /* returned (may be passed as FVECT cp[2][2]) */ -register HOLO *hp; -register GCOORD *gc; +extern void +hdcell( /* compute cell coordinates */ + register FVECT cp[4], /* returned (may be passed as FVECT cp[2][2]) */ + register HOLO *hp, + register GCOORD *gc +) { - register FLOAT *v; + register RREAL *v; double d; /* compute common component */ VCOPY(cp[0], hp->orig); @@ -164,10 +168,12 @@ register GCOORD *gc; } -hdlseg(lseg, hp, gc) /* compute line segment for beam */ -register int lseg[2][3]; -register HOLO *hp; -GCOORD gc[2]; +extern int +hdlseg( /* compute line segment for beam */ + register int lseg[2][3], + register HOLO *hp, + GCOORD gc[2] +) { register int k; @@ -180,10 +186,11 @@ GCOORD gc[2]; } -unsigned -hdcode(hp, d) /* compute depth code for d */ -HOLO *hp; -double d; +extern unsigned int +hdcode( /* compute depth code for d */ + HOLO *hp, + double d +) { double tl = hp->tlin; register long c; @@ -199,10 +206,12 @@ double d; } -hdgrid(gp, hp, wp) /* compute grid coordinates */ -FVECT gp; /* returned */ -register HOLO *hp; -FVECT wp; +extern void +hdgrid( /* compute grid coordinates */ + FVECT gp, /* returned */ + register HOLO *hp, + FVECT wp +) { FVECT vt; @@ -213,10 +222,12 @@ FVECT wp; } -hdworld(wp, hp, gp) /* compute world coordinates */ -register FVECT wp; -register HOLO *hp; -FVECT gp; +extern void +hdworld( /* compute world coordinates */ + register FVECT wp, + register HOLO *hp, + FVECT gp +) { register double d; @@ -231,12 +242,14 @@ FVECT gp; } -double -hdray(ro, rd, hp, gc, r) /* compute ray within a beam */ -FVECT ro, rd; /* returned */ -HOLO *hp; -GCOORD gc[2]; -BYTE r[2][2]; +extern double +hdray( /* compute ray within a beam */ + FVECT ro, + FVECT rd, /* returned */ + HOLO *hp, + GCOORD gc[2], + BYTE r[2][2] +) { FVECT cp[4], p[2]; register int i, j; @@ -256,17 +269,19 @@ BYTE r[2][2]; } -double -hdinter(gc, r, ed, hp, ro, rd) /* compute ray intersection with section */ -register GCOORD gc[2]; /* returned */ -BYTE r[2][2]; /* returned (optional) */ -double *ed; /* returned (optional) */ -register HOLO *hp; -FVECT ro, rd; /* normalization of rd affects distances */ +extern double +hdinter( /* compute ray intersection with section */ + register GCOORD gc[2], /* returned */ + BYTE r[2][2], /* returned (optional) */ + double *ed, /* returned (optional) */ + register HOLO *hp, + FVECT ro, + FVECT rd /* normalization of rd affects distances */ +) { FVECT p[2], vt; double d, t0, t1, d0, d1; - register FLOAT *v; + register RREAL *v; register int i; /* first, intersect walls */ gc[0].w = gc[1].w = -1; @@ -299,7 +314,7 @@ FVECT ro, rd; /* normalization of rd affects distance } } } - if (gc[0].w < 0 | gc[1].w < 0) /* paranoid check */ + if ((gc[0].w < 0) | (gc[1].w < 0)) /* paranoid check */ return(FHUGE); /* compute intersections */ VSUM(p[0], ro, rd, t0);