--- ray/src/hd/rhdisp2.c 1997/11/21 18:17:37 3.5 +++ ray/src/hd/rhdisp2.c 1997/11/25 10:48:38 3.7 @@ -14,6 +14,8 @@ static char SCCSid[] = "$SunId$ SGI"; extern GCOORD *getviewcells(); +static VIEW dvw; /* current view corresponding to beam list */ + typedef struct { int hd; /* holodeck section number (-1 if inactive) */ int i[3]; /* voxel index (may be outside section) */ @@ -361,10 +363,11 @@ VIEW *vold, *vnew; struct cellact oca, nca; int ocnt, ncnt; int c; + GCOORD *ogcl, *ngcl; register GCOORD *ogcp, *ngcp; /* get old and new cell lists */ - ogcp = getviewcells(&ocnt, hdlist[voxel[voxi].hd], vold); - ngcp = getviewcells(&ncnt, hdlist[voxel[voxi].hd], vnew); + ogcp = ogcl = getviewcells(&ocnt, hdlist[voxel[voxi].hd], vold); + ngcp = ngcl = getviewcells(&ncnt, hdlist[voxel[voxi].hd], vnew); /* set up actions */ oca.vi = nca.vi = voxi; oca.rev = nca.rev = 0; @@ -373,29 +376,26 @@ VIEW *vold, *vnew; ocnt = -ocnt; if ((nca.rev = ncnt < 0)) ncnt = -ncnt; - /* add and delete cells in order */ - while (ocnt > 0 & ncnt > 0) - if ((c = cellcmp(ogcp, ngcp)) > 0) { /* new cell */ - netchange += docell(ngcp++, &nca); - ncnt--; - } else if (c < 0) { /* obsolete cell */ - netchange -= docell(ogcp++, &oca); - ocnt--; - } else { /* same cell? */ - if (oca.rev != nca.rev) /* not */ - netchange += docell(ngcp, &nca) - - docell(ogcp, &oca); - ogcp++; ocnt--; - ngcp++; ncnt--; - } + if (nca.rev == oca.rev) /* add and delete cells in order */ + while (ocnt > 0 & ncnt > 0) + if ((c = cellcmp(ogcp, ngcp)) > 0) { /* new cell */ + netchange += docell(ngcp++, &nca); + ncnt--; + } else if (c < 0) { /* old cell */ + netchange -= docell(ogcp++, &oca); + ocnt--; + } else { /* same cell */ + ogcp++; ocnt--; + ngcp++; ncnt--; + } /* take care of list tails */ for ( ; ncnt > 0; ncnt--) netchange += docell(ngcp++, &nca); for ( ; ocnt > 0; ocnt--) netchange -= docell(ogcp++, &oca); /* clean up */ - if (ogcp != NULL) free((char *)ogcp); - if (ngcp != NULL) free((char *)ngcp); + if (ogcl != NULL) free((char *)ogcl); + if (ngcl != NULL) free((char *)ngcl); return(netchange); } @@ -406,8 +406,8 @@ beam_sync() /* synchronize beams on server */ } -beam_view(vo, vn) /* change beam view */ -VIEW *vo, *vn; +beam_view(vn) /* change beam view */ +VIEW *vn; { struct cellact ca; VOXL vlnew[8]; @@ -417,18 +417,19 @@ VIEW *vo, *vn; set_voxels(vlnew, 0); cbeamop(DR_DELSET, cbeam, ncbeams, NULL, 0, 0); ncbeams = 0; + copystruct(&dvw, vn); return; } /* find our new voxels */ n = get_voxels(vlnew, vn->vp); /* set the new voxels */ comn = set_voxels(vlnew, n); - if (!vo->type) + if (!dvw.type) comn = 0; ca.add = 1; /* update our beam list */ for (ca.vi = n; ca.vi--; ) if (comn & 1<