--- ray/src/hd/holo.c 1997/11/03 11:03:23 3.2 +++ ray/src/hd/holo.c 1997/11/11 14:40:59 3.4 @@ -104,13 +104,13 @@ HDGRID *hproto; hdbcoord(gc, hp, i) /* compute beam coordinates from index */ -BCOORD gc; /* returned */ +GCOORD gc[2]; /* returned */ register HOLO *hp; register int i; { register int j, n; int n2, reverse; - BCOORD g2; + GCOORD g2[2]; /* check range */ if (i < 1 | i > nbeams(hp)) return(0); @@ -150,9 +150,9 @@ register int i; int hdbindex(hp, gc) /* compute index from beam coordinates */ register HOLO *hp; -register BCOORD gc; +register GCOORD gc[2]; { - BCOORD g2; + GCOORD g2[2]; int reverse; register int i, j; /* check ordering and limits */ @@ -178,12 +178,38 @@ register BCOORD gc; } +hdcell(cp, hp, gc) /* compute cell coordinates */ +register FVECT cp[4]; /* returned (may be passed as FVECT cp[2][2]) */ +HOLO *hp; +register GCOORD *gc; +{ + register int i; + register FLOAT *v; + double d; + /* compute each corner */ + for (i = 0; i < 4; i++) { + VCOPY(cp[i], hp->orig); + if (gc->w & 1) { + v = hp->xv[gc->w>>1]; + cp[i][0] += *v++; cp[i][1] += *v++; cp[i][2] += *v; + } + d = (double)( gc->i[0] + (i&1) ) / hp->grid[wg0[gc->w]]; + v = hp->xv[wg0[gc->w]]; + cp[i][0] += d * *v++; cp[i][1] += d * *v++; cp[i][2] += d * *v; + + d = (double)( gc->i[1] + (i>>1) ) / hp->grid[wg1[gc->w]]; + v = hp->xv[wg1[gc->w]]; + cp[i][0] += d * *v++; cp[i][1] += d * *v++; cp[i][2] += d * *v; + } +} + + hdlseg(lseg, hp, i) /* compute line segment for beam */ register int lseg[2][3]; register HOLO *hp; int i; { - BCOORD gc; + GCOORD gc[2]; register int k; if (!hdbcoord(gc, hp, i)) /* compute grid coordinates */ @@ -220,7 +246,7 @@ double hdray(ro, rd, hp, gc, r) /* compute ray within a beam */ FVECT ro, rd; /* returned */ register HOLO *hp; -register BCOORD gc; +register GCOORD gc[2]; BYTE r[2][2]; { FVECT p[2]; @@ -238,7 +264,7 @@ BYTE r[2][2]; hp->grid[wg0[gc[i].w]]; v = hp->xv[wg0[gc[i].w]]; p[i][0] += d * *v++; p[i][1] += d * *v++; p[i][2] += d * *v; - d = (gc[i].i[1] + (1./256.)*(r[i][1]+.5)) / + d = ( gc[i].i[1] + (1./256.)*(r[i][1]+.5) ) / hp->grid[wg1[gc[i].w]]; v = hp->xv[wg1[gc[i].w]]; p[i][0] += d * *v++; p[i][1] += d * *v++; p[i][2] += d * *v; @@ -253,7 +279,7 @@ BYTE r[2][2]; double hdinter(gc, r, hp, ro, rd) /* compute ray intersection with section */ -register BCOORD gc; /* returned */ +register GCOORD gc[2]; /* returned */ BYTE r[2][2]; /* returned */ register HOLO *hp; FVECT ro, rd; /* rd should be normalized */