1 |
< |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
– |
cbeamadj(v, hr, vr) /* adjust our beam list */ |
168 |
– |
VIEW *v; |
169 |
– |
int hr, vr; |
170 |
– |
{ |
171 |
– |
register PACKHEAD *pa; |
172 |
– |
register int i; |
173 |
– |
int n; |
174 |
– |
/* first handle additions */ |
175 |
– |
pa = (PACKHEAD *)malloc(xcbeams*sizeof(PACKHEAD)); |
176 |
– |
if (xcbeams && pa == NULL) |
177 |
– |
goto memerr; |
178 |
– |
for (i = xcbeams; i--; ) { |
179 |
– |
pa[i].hd = cbeam[ncbeams+i].hd; |
180 |
– |
pa[i].bi = cbeam[ncbeams+i].bi; |
181 |
– |
pa[i].nr = npixels(v, hr, vr, hdlist[pa[i].hd], pa[i].bi) + 1; |
182 |
– |
} |
183 |
– |
n = xcbeams; /* now sort list for deletions */ |
184 |
– |
cbeamsort(0); |
185 |
– |
pa = (PACKHEAD *)realloc((char *)pa, (n+xcbeams)*sizeof(PACKHEAD)); |
186 |
– |
if (n+xcbeams && pa == NULL) |
187 |
– |
goto memerr; |
188 |
– |
for (i = xcbeams; i--; ) { |
189 |
– |
pa[n+i].hd = cbeam[ncbeams+i].hd; |
190 |
– |
pa[n+i].bi = cbeam[ncbeams+i].bi; |
191 |
– |
pa[n+i].nr = 0; |
192 |
– |
} |
193 |
– |
n += xcbeams; |
194 |
– |
xcbeams = 0; /* delete orphans */ |
195 |
– |
serv_request(DR_ADJSET, n*sizeof(PACKHEAD), (char *)pa); |
196 |
– |
free((char *)pa); |
197 |
– |
return; |
198 |
– |
memerr: |
199 |
– |
error(SYSTEM, "out of memory in cbeamadj"); |
200 |
– |
} |
201 |
– |
|
202 |
– |
|
167 |
|
cbeamop(op, bl, n, v, hr, vr) /* update beams on server list */ |
168 |
|
int op; |
169 |
|
register struct beamcomp *bl; |
184 |
|
pa[i].bi = bl[i].bi; |
185 |
|
pa[i].nr = v==NULL ? 0 : |
186 |
|
npixels(v, hr, vr, hdlist[bl[i].hd], bl[i].bi); |
187 |
+ |
pa[i].nc = 0; |
188 |
|
} |
189 |
|
serv_request(op, n*sizeof(PACKHEAD), (char *)pa); |
190 |
|
free((char *)pa); |
235 |
|
VOXL vl[8]; |
236 |
|
FVECT vp; |
237 |
|
{ |
273 |
– |
static int lastn = 0, lastd = -1; |
238 |
|
int n = 0; |
239 |
|
FVECT gp; |
240 |
|
double d; |
270 |
|
error(COMMAND, "move past outer limits"); |
271 |
|
return(0); |
272 |
|
} |
273 |
< |
/* warn of dangerous moves */ |
310 |
< |
if (n < lastn && bestd >= lastd) |
311 |
< |
error(WARNING, "moving outside holodeck section"); |
312 |
< |
else if (n > lastn && bestd <= lastd) |
313 |
< |
error(WARNING, "moving inside holodeck section"); |
314 |
< |
lastd = bestd; |
315 |
< |
return(lastn = n); |
273 |
> |
return(n); |
274 |
|
} |
275 |
|
|
276 |
|
|
322 |
|
register int i; |
323 |
|
/* compute cell center */ |
324 |
|
cgp[gcp->w>>1] = gcp->w&1 ? hp->grid[gcp->w>>1] : 0 ; |
325 |
< |
cgp[((gcp->w>>1)+1)%3] = gcp->i[0] + .5; |
326 |
< |
cgp[((gcp->w>>1)+2)%3] = gcp->i[1] + .5; |
325 |
> |
cgp[hdwg0[gcp->w]] = gcp->i[0] + .5; |
326 |
> |
cgp[hdwg1[gcp->w]] = gcp->i[1] + .5; |
327 |
|
hdworld(org, hp, cgp); |
328 |
|
/* compute direction to voxel center */ |
329 |
|
for (i = 3; i--; ) |
350 |
|
for (i = 3; i--; ) |
351 |
|
v1[i] = hp->xv[j][i] * d; |
352 |
|
d = 0.5/hp->grid[j=(axmax+2)%3]; |
353 |
< |
if (DOT(hp->wn[axmax], vc) < 0.) |
354 |
< |
d = -d; /* reverse vertex ordering */ |
353 |
> |
if (DOT(hp->wg[axmax], vc) < 0.) |
354 |
> |
d = -d; /* reverse vertex order */ |
355 |
|
for (i = 3; i--; ) |
356 |
|
v2[i] = hp->xv[j][i] * d; |
357 |
|
/* compute voxel pyramid */ |
392 |
|
int netchange = 0; |
393 |
|
struct cellact oca, nca; |
394 |
|
int ocnt, ncnt; |
395 |
< |
int c; |
395 |
> |
int nmatch = 0; |
396 |
|
GCOORD *ogcl, *ngcl; |
397 |
+ |
register int c; |
398 |
|
register GCOORD *ogcp, *ngcp; |
399 |
|
/* get old and new cell lists */ |
400 |
|
ogcp = ogcl = getviewcells(&ocnt, hdlist[voxel[voxi].hd], vold); |
406 |
|
ocnt = -ocnt; |
407 |
|
if ((nca.rev = ncnt < 0)) |
408 |
|
ncnt = -ncnt; |
409 |
< |
if (nca.rev == oca.rev) /* add and delete cells in order */ |
410 |
< |
while (ocnt > 0 & ncnt > 0) |
411 |
< |
if ((c = cellcmp(ogcp, ngcp)) > 0) { /* new cell */ |
412 |
< |
netchange += docell(ngcp++, &nca); |
413 |
< |
ncnt--; |
414 |
< |
} else if (c < 0) { /* old cell */ |
415 |
< |
netchange -= docell(ogcp++, &oca); |
416 |
< |
ocnt--; |
417 |
< |
} else { /* same cell */ |
418 |
< |
ogcp++; ocnt--; |
419 |
< |
ngcp++; ncnt--; |
409 |
> |
if (oca.rev == nca.rev) { /* count matches */ |
410 |
> |
int oc = ocnt, nc = ncnt; |
411 |
> |
while (oc > 0 & nc > 0) { |
412 |
> |
c = cellcmp(ogcp, ngcp); |
413 |
> |
if (c >= 0) { ngcp++; nc--; } |
414 |
> |
if (c <= 0) { ogcp++; oc--; } |
415 |
> |
nmatch += c==0; |
416 |
> |
} |
417 |
> |
ogcp = ogcl; ngcp = ngcl; |
418 |
> |
} |
419 |
> |
if (nmatch < ocnt>>1) { /* faster to just delete old cells? */ |
420 |
> |
for (c = ncbeams; c--; ) |
421 |
> |
if (cbeam[c].wants & 1<<voxi) { |
422 |
> |
cbeam[c].wants &= ~(1<<voxi); |
423 |
> |
netchange--; |
424 |
|
} |
425 |
+ |
free((char *)ogcl); |
426 |
+ |
ogcl = NULL; ocnt = 0; |
427 |
+ |
} |
428 |
+ |
/* add and delete cells in order */ |
429 |
+ |
while (ocnt > 0 & ncnt > 0) |
430 |
+ |
if ((c = cellcmp(ogcp, ngcp)) > 0) { /* new cell */ |
431 |
+ |
netchange += docell(ngcp++, &nca); |
432 |
+ |
ncnt--; |
433 |
+ |
} else if (c < 0) { /* old cell */ |
434 |
+ |
netchange -= docell(ogcp++, &oca); |
435 |
+ |
ocnt--; |
436 |
+ |
} else { /* same cell */ |
437 |
+ |
ogcp++; ocnt--; |
438 |
+ |
ngcp++; ncnt--; |
439 |
+ |
} |
440 |
|
/* take care of list tails */ |
441 |
|
for ( ; ncnt > 0; ncnt--) |
442 |
|
netchange += docell(ngcp++, &nca); |
487 |
|
mvview(ca.vi, &dvw, vn); |
488 |
|
else /* else add all new cells */ |
489 |
|
doview(&ca, vn); |
512 |
– |
#if 1 |
513 |
– |
cbeamadj(vn, odev.hres, odev.vres); |
514 |
– |
#else |
490 |
|
/* inform server of new beams */ |
491 |
|
cbeamop(DR_ADDSET, cbeam+ncbeams, xcbeams, vn, odev.hres, odev.vres); |
492 |
|
/* sort list to put orphans at end */ |
494 |
|
/* tell server to delete orphans */ |
495 |
|
cbeamop(DR_DELSET, cbeam+ncbeams, xcbeams, NULL, 0, 0); |
496 |
|
xcbeams = 0; /* truncate our list */ |
522 |
– |
#endif |
497 |
|
copystruct(&dvw, vn); /* record new view */ |
498 |
|
return(1); |
499 |
|
} |