| 5 |
|
* Routines for tracking beam compuatations |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
– |
#include <time.h> |
| 9 |
– |
#include <string.h> |
| 10 |
– |
#include <stdio.h> |
| 11 |
– |
|
| 12 |
– |
#include "view.h" |
| 8 |
|
#include "rholo.h" |
| 9 |
|
|
| 10 |
|
#ifndef NFRAG2CHUNK |
| 11 |
|
#define NFRAG2CHUNK 4096 /* number of fragments to start chunking */ |
| 12 |
|
#endif |
| 13 |
|
|
| 14 |
+ |
#ifndef MAXADISK |
| 15 |
+ |
#define MAXADISK 10240. /* maximum holodeck size (Megs) for ambient */ |
| 16 |
+ |
#endif |
| 17 |
+ |
|
| 18 |
|
#ifndef abs |
| 19 |
|
#define abs(x) ((x) > 0 ? (x) : -(x)) |
| 20 |
|
#endif |
| 42 |
|
|
| 43 |
|
static int |
| 44 |
|
beamcmp(b0, b1) /* comparison for compute order */ |
| 45 |
< |
register PACKHEAD *b0, *b1; |
| 45 |
> |
PACKHEAD *b0, *b1; |
| 46 |
|
{ |
| 47 |
|
BEAMI *bip0, *bip1; |
| 48 |
< |
register long c; |
| 48 |
> |
long c; |
| 49 |
|
/* first check desired quantities */ |
| 50 |
|
if (chunkycmp) |
| 51 |
|
c = rchunk(b1->nr)*(rchunk(b0->nc)+1L) - |
| 75 |
|
|
| 76 |
|
int |
| 77 |
|
beamidcmp(b0, b1) /* comparison for beam searching */ |
| 78 |
< |
register PACKHEAD *b0, *b1; |
| 78 |
> |
PACKHEAD *b0, *b1; |
| 79 |
|
{ |
| 80 |
< |
register int c = b0->hd - b1->hd; |
| 80 |
> |
int c = b0->hd - b1->hd; |
| 81 |
|
|
| 82 |
|
if (c) return(c); |
| 83 |
|
return(b0->bi - b1->bi); |
| 86 |
|
|
| 87 |
|
static void |
| 88 |
|
dispbeam( /* display a holodeck beam */ |
| 89 |
< |
register BEAM *b, |
| 90 |
< |
register HDBEAMI *hb |
| 89 |
> |
BEAM *b, |
| 90 |
> |
HDBEAMI *hb |
| 91 |
|
) |
| 92 |
|
{ |
| 93 |
|
static int n = 0; |
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
|
| 119 |
< |
extern void |
| 119 |
> |
void |
| 120 |
|
bundle_set( /* bundle set operation */ |
| 121 |
|
int op, |
| 122 |
|
PACKHEAD *clist, |
| 125 |
|
{ |
| 126 |
|
int oldnr, n; |
| 127 |
|
HDBEAMI *hbarr; |
| 128 |
< |
register PACKHEAD *csm; |
| 129 |
< |
register int i; |
| 128 |
> |
PACKHEAD *csm; |
| 129 |
> |
int i; |
| 130 |
|
/* search for common members */ |
| 131 |
|
for (csm = clist+nents; csm-- > clist; ) |
| 132 |
|
csm->nc = -1; |
| 247 |
|
FVECT cp[4], edgeA, edgeB, cent[2]; |
| 248 |
|
FVECT crossp[2], diffv; |
| 249 |
|
double vol[2]; |
| 250 |
< |
register int i; |
| 250 |
> |
int i; |
| 251 |
|
/* get grid coordinates */ |
| 252 |
|
if (!hdbcoord(gc, hp, bi)) |
| 253 |
|
error(CONSISTENCY, "bad beam index in beamvolume"); |
| 274 |
|
static void |
| 275 |
|
ambient_list(void) /* compute ambient beam list */ |
| 276 |
|
{ |
| 277 |
< |
int32 wtotal, minrt; |
| 277 |
> |
unsigned long wtotal; |
| 278 |
> |
int32 minrt; |
| 279 |
|
double frac; |
| 280 |
|
int i; |
| 281 |
< |
register int j, k; |
| 281 |
> |
int j, k; |
| 282 |
|
|
| 283 |
|
complen = 0; |
| 284 |
|
for (j = 0; hdlist[j] != NULL; j++) |
| 288 |
|
/* compute beam weights */ |
| 289 |
|
k = 0; wtotal = 0; |
| 290 |
|
for (j = 0; hdlist[j] != NULL; j++) { |
| 291 |
+ |
/* 512. arbitrary -- adjusted below */ |
| 292 |
|
frac = 512. * VLEN(hdlist[j]->wg[0]) * |
| 293 |
|
VLEN(hdlist[j]->wg[1]) * |
| 294 |
|
VLEN(hdlist[j]->wg[2]); |
| 304 |
|
if (vdef(DISKSPACE)) |
| 305 |
|
frac = 1024.*1024.*vflt(DISKSPACE) / (wtotal*sizeof(RAYVAL)); |
| 306 |
|
else |
| 307 |
< |
frac = 1024.*1024.*2048. / (wtotal*sizeof(RAYVAL)); |
| 308 |
< |
minrt = .02*frac*wtotal/complen + .5; /* heuristic mimimum */ |
| 307 |
> |
frac = 1024.*1024.*MAXADISK / (wtotal*sizeof(RAYVAL)); |
| 308 |
> |
minrt = .02*frac*wtotal/complen + 1.1; /* heuristic mimimum */ |
| 309 |
|
if (minrt > RPACKSIZ) |
| 310 |
|
minrt = RPACKSIZ; |
| 311 |
|
for (k = complen; k--; ) |
| 341 |
|
} |
| 342 |
|
|
| 343 |
|
|
| 344 |
< |
extern void |
| 344 |
> |
void |
| 345 |
|
init_global(void) /* initialize global ray computation */ |
| 346 |
|
{ |
| 347 |
|
/* free old list and empty queue */ |
| 363 |
|
|
| 364 |
|
static void |
| 365 |
|
mergeclists( /* merge two sorted lists */ |
| 366 |
< |
register PACKHEAD *cdest, |
| 367 |
< |
register PACKHEAD *cl1, |
| 366 |
> |
PACKHEAD *cdest, |
| 367 |
> |
PACKHEAD *cl1, |
| 368 |
|
int n1, |
| 369 |
< |
register PACKHEAD *cl2, |
| 369 |
> |
PACKHEAD *cl2, |
| 370 |
|
int n2 |
| 371 |
|
) |
| 372 |
|
{ |
| 373 |
< |
register int cmp; |
| 373 |
> |
int cmp; |
| 374 |
|
|
| 375 |
|
while (n1 | n2) { |
| 376 |
|
if (!n1) cmp = 1; |
| 393 |
|
{ |
| 394 |
|
PACKHEAD *list2; |
| 395 |
|
int listlen; |
| 396 |
< |
register int i; |
| 396 |
> |
int i; |
| 397 |
|
|
| 398 |
|
if (complen <= 0) /* check to see if there is even a list */ |
| 399 |
|
return; |
| 447 |
|
* list and start again from the beginning. Since |
| 448 |
|
* a merge sort is used, the sorting costs are minimal. |
| 449 |
|
*/ |
| 450 |
< |
extern int |
| 450 |
> |
int |
| 451 |
|
next_packet( /* prepare packet for computation */ |
| 452 |
< |
register PACKET *p, |
| 452 |
> |
PACKET *p, |
| 453 |
|
int n |
| 454 |
|
) |
| 455 |
|
{ |