| 5 |
|
#endif |
| 6 |
|
|
| 7 |
|
/* |
| 8 |
< |
* Holodeck beam tracking |
| 8 |
> |
* Holodeck beam tracking for display process |
| 9 |
|
*/ |
| 10 |
|
|
| 11 |
|
#include "rholo.h" |
| 15 |
|
extern int *getviewcells(); |
| 16 |
|
|
| 17 |
|
typedef struct { |
| 18 |
< |
int hd; /* holodeck section number */ |
| 18 |
> |
int hd; /* holodeck section number (-1 if inactive) */ |
| 19 |
|
int i[3]; /* voxel index (may be outside section) */ |
| 20 |
|
} VOXL; /* a voxel */ |
| 21 |
|
|
| 36 |
|
static int xcbeams = 0; /* extra (unregistered) beams past ncbeams */ |
| 37 |
|
static int maxcbeam = 0; /* size of cbeam array */ |
| 38 |
|
|
| 39 |
– |
|
| 39 |
|
struct cellact { |
| 40 |
|
short vi; /* voxel index */ |
| 41 |
|
short add; /* zero means delete */ |
| 42 |
|
}; /* action for cell */ |
| 43 |
|
|
| 45 |
– |
|
| 44 |
|
struct beamact { |
| 45 |
|
struct cellact ca; /* cell action */ |
| 46 |
|
GCOORD gc; /* grid coordinate */ |
| 245 |
|
VOXL vl[8]; |
| 246 |
|
FVECT vp; |
| 247 |
|
{ |
| 248 |
+ |
static int lastn = 0, lastd = -1; |
| 249 |
|
int n = 0; |
| 250 |
|
FVECT gp; |
| 251 |
|
double d; |
| 276 |
|
n++; |
| 277 |
|
} |
| 278 |
|
} |
| 279 |
< |
return(n); |
| 279 |
> |
/* warn of dangerous moves */ |
| 280 |
> |
if (n < lastn && bestd >= lastd) |
| 281 |
> |
error(WARNING, "moving outside holodeck section"); |
| 282 |
> |
else if (n > lastn && bestd <= lastd) |
| 283 |
> |
error(WARNING, "moving inside holodeck section"); |
| 284 |
> |
lastd = bestd; |
| 285 |
> |
return(lastn = n); |
| 286 |
|
} |
| 287 |
|
|
| 288 |
|
|
| 297 |
|
copystruct(gc, gcp); |
| 298 |
|
copystruct(gc+1, &bp->gc); |
| 299 |
|
if ((bi = hdbindex(hdlist[voxel[bp->ca.vi].hd], gc)) <= 0) |
| 300 |
< |
return(0); /* should report an error? */ |
| 300 |
> |
error(CONSISTENCY, "bad grid coordinate in dobeam"); |
| 301 |
|
if (bp->ca.add) { /* add it in */ |
| 302 |
|
i = getcbeam(voxel[bp->ca.vi].hd, bi); |
| 303 |
|
cbeam[i].wants |= 1<<bp->ca.vi; /* say we want it */ |
| 408 |
|
} |
| 409 |
|
/* take care of list tails */ |
| 410 |
|
for (ca.add = 1; ncnt > 0; ncnt--) |
| 411 |
< |
docell(ngcp++, &ca); |
| 411 |
> |
netchange += docell(ngcp++, &ca); |
| 412 |
|
for (ca.add = 0; ocnt > 0; ocnt--) |
| 413 |
< |
docell(ogcp++, &ca); |
| 413 |
> |
netchange -= docell(ogcp++, &ca); |
| 414 |
|
/* clean up */ |
| 415 |
|
if (ocl != NULL) free((char *)ocl); |
| 416 |
|
if (ncl != NULL) free((char *)ncl); |