1 |
< |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
/* SCCSid "$SunId$ SGI" */ |
4 |
|
|
14 |
|
#ifndef HDMAX |
15 |
|
#define HDMAX 128 /* maximum active holodeck sections */ |
16 |
|
#endif |
17 |
< |
#ifndef int2 |
18 |
< |
#define int2 short |
17 |
> |
|
18 |
> |
#ifndef MAXDIRSE |
19 |
> |
#define MAXDIRSE 32 /* maximum seeks per directory write */ |
20 |
|
#endif |
20 |
– |
#ifndef int4 |
21 |
– |
#define int4 long |
22 |
– |
#endif |
21 |
|
|
22 |
|
#define DCINF (unsigned)((1L<<16)-1) /* special value for infinity */ |
23 |
|
#define DCLIN (unsigned)(1L<<11) /* linear depth limit */ |
24 |
|
|
25 |
|
typedef struct { |
26 |
|
BYTE r[2][2]; /* ray direction index */ |
27 |
< |
COLR v; /* value */ |
28 |
< |
unsigned int2 d; /* depth code */ |
29 |
< |
} RAYVAL; /* ray value (from second wall) */ |
27 |
> |
COLR v; /* color value */ |
28 |
> |
unsigned int2 d; /* depth code (from entry wall) */ |
29 |
> |
} RAYVAL; /* ray value */ |
30 |
|
|
31 |
|
/* |
32 |
|
* Walls are ordered: X0 X1 X2 WN |
55 |
|
unsigned long tick; /* clock tick for LRU replacement */ |
56 |
|
} BEAM; /* followed by nrm RAYVAL's */ |
57 |
|
|
58 |
< |
#define hdbray(bp) (RAYVAL *)((bp)+1) |
58 |
> |
#define hdbray(bp) ((RAYVAL *)((bp)+1)) |
59 |
|
#define hdbsiz(nr) (sizeof(BEAM)+(nr)*sizeof(RAYVAL)) |
60 |
|
|
61 |
|
typedef struct { |
69 |
|
FVECT xv[3]; /* side vectors (second) */ |
70 |
|
int2 grid[3]; /* grid resolution (third) */ |
71 |
|
int fd; /* file descriptor */ |
72 |
< |
short dirty; /* beam index needs update to file */ |
72 |
> |
struct { |
73 |
> |
int s, n; /* dirty section start, length */ |
74 |
> |
} dirseg[MAXDIRSE+1]; /* dirty beam index segments */ |
75 |
> |
short dirty; /* number of dirty segments */ |
76 |
|
double tlin; /* linear range for depth encoding */ |
77 |
< |
FVECT wn[3]; /* wall normals (derived) */ |
78 |
< |
double wo[6]; /* wall offsets (derived) */ |
78 |
< |
FVECT gv[3][2]; /* grid coordinate vectors (derived) */ |
77 |
> |
FVECT wg[3]; /* wall grid vectors (derived) */ |
78 |
> |
double wo[6]; /* wall grid offsets (derived) */ |
79 |
|
int wi[6]; /* wall super-indices (derived) */ |
80 |
|
char *priv; /* pointer to private client data */ |
81 |
|
BEAM **bl; /* beam pointers (memory cache) */ |
82 |
|
BEAMI bi[1]; /* beam index (extends struct) */ |
83 |
|
} HOLO; /* holodeck section */ |
84 |
|
|
85 |
< |
#define nbeams(hp) (2*((hp)->wi[5]-1)) |
85 |
> |
typedef struct { |
86 |
> |
HOLO *h; /* pointer to holodeck */ |
87 |
> |
int b; /* beam index */ |
88 |
> |
} HDBEAMI; /* holodeck beam index */ |
89 |
> |
|
90 |
> |
#define nbeams(hp) (((hp)->wi[5]-1)<<1) |
91 |
|
#define biglob(hp) ((hp)->bi) |
92 |
|
#define blglob(hp) (*(hp)->bl) |
93 |
|
|
94 |
|
#define bnrays(hp,i) ((hp)->bl[i]!=NULL ? (hp)->bl[i]->nrm : (hp)->bi[i].nrd) |
95 |
|
|
96 |
< |
#define hdflush(hp) (hdfreebeam(hp,0) && hdsync(hp)) |
96 |
> |
#define hdflush(hp) (hdfreebeam(hp,0), hdsync(hp,0)) |
97 |
> |
#define hdclobber(hp) (hdkillbeam(hp,0), hdsync(hp,0)) |
98 |
|
|
99 |
< |
extern HOLO *hdinit(); |
99 |
> |
extern HOLO *hdinit(), *hdalloc(); |
100 |
|
extern BEAM *hdgetbeam(); |
101 |
|
extern RAYVAL *hdnewrays(); |
102 |
< |
extern long hdmemuse(), hdfiluse(); |
102 |
> |
extern unsigned hdmemuse(); |
103 |
> |
extern long hdfiluse(), hdfilen(), hdallocfrag(); |
104 |
|
extern double hdray(), hdinter(); |
105 |
|
extern unsigned hdcode(); |
106 |
+ |
extern int hdfilord(); |
107 |
|
|
108 |
< |
extern int hdcachesize; /* target cache size (bytes) */ |
108 |
> |
extern unsigned hdcachesize; /* target cache size (bytes) */ |
109 |
|
extern unsigned long hdclock; /* holodeck system clock */ |
110 |
|
extern HOLO *hdlist[HDMAX+1]; /* holodeck pointers (NULL term.) */ |
111 |
|
|
112 |
|
extern float hd_depthmap[]; /* depth conversion map */ |
113 |
|
|
114 |
+ |
extern int hdwg0[6]; /* wall grid 0 index */ |
115 |
+ |
extern int hdwg1[6]; /* wall grid 1 index */ |
116 |
+ |
|
117 |
|
#define hddepth(hp,dc) ( (dc) >= DCINF ? FHUGE : \ |
118 |
|
(hp)->tlin * ( (dc) >= DCLIN ? \ |
119 |
|
hd_depthmap[(dc)-DCLIN] : \ |
121 |
|
|
122 |
|
#define HOLOFMT "Holodeck" /* file format identifier */ |
123 |
|
#define HOLOVERS 0 /* file format version number */ |
124 |
< |
#define HOLOMAGIC (327+HOLOVERS) /* file magic number */ |
124 |
> |
#define HOLOMAGIC (323+sizeof(long)+8*HOLOVERS) /* file magic number */ |
125 |
|
|
126 |
|
/* |
127 |
|
* A holodeck file consists of an information header terminated by a |
128 |
|
* blank line, with "FORMAT=Holodeck" somewhere in it. |
129 |
|
* The first integer after the information header is the |
130 |
|
* above magic number, which includes the file format version number. |
131 |
< |
* The first longword after the magic number is the position |
132 |
< |
* of the SECOND holodeck section, or 0 if there is only one. |
131 |
> |
* The first longword after the magic number is a pointer to the pointer |
132 |
> |
* just before the SECOND holodeck section, or 0 if there is only one. |
133 |
|
* This longword is immediately followed by the first holodeck |
134 |
|
* section header and directory. |
135 |
|
* Similarly, every holodeck section in the file is preceeded by |