ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/holo.h
Revision: 3.22
Committed: Fri Jun 20 00:25:49 2003 UTC (20 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 3.21: +6 -6 lines
Log Message:
Changed instances of "int4" to "int32" and "int2" to "int16"

File Contents

# User Rev Content
1 greg 3.22 /* RCSid: $Id: holo.h,v 3.21 2003/05/29 16:26:21 greg Exp $ */
2 gregl 3.1 /*
3     * Header file for holodeck programs
4     *
5     * 9/29/97 GWLarson
6     */
7    
8     #include "standard.h"
9     #include "color.h"
10    
11     #ifndef HDMAX
12     #define HDMAX 128 /* maximum active holodeck sections */
13     #endif
14    
15 gwlarson 3.17 #ifndef MAXDIRSE
16     #define MAXDIRSE 32 /* maximum seeks per directory write */
17     #endif
18    
19 gregl 3.1 #define DCINF (unsigned)((1L<<16)-1) /* special value for infinity */
20     #define DCLIN (unsigned)(1L<<11) /* linear depth limit */
21    
22     typedef struct {
23     BYTE r[2][2]; /* ray direction index */
24 gwlarson 3.15 COLR v; /* color value */
25 greg 3.22 uint16 d; /* depth code (from entry wall) */
26 gwlarson 3.15 } RAYVAL; /* ray value */
27 gregl 3.1
28     /*
29     * Walls are ordered: X0 X1 X2 WN
30     * 0 ? ? 0
31     * 1 ? ? 1
32     * ? 0 ? 2
33     * ? 1 ? 3
34     * ? ? 0 4
35     * ? ? 1 5
36     *
37     * Grid on wall WN corresponds to X(WN/2+1)%3 and X(WN/2+2)%3, resp.
38     */
39    
40     typedef struct {
41     short w; /* wall number */
42     short i[2]; /* index on wall grid */
43 gregl 3.2 } GCOORD; /* grid coordinates (two for beam) */
44 gregl 3.1
45     typedef struct {
46 greg 3.22 uint32 nrd; /* number of beam rays bundled on disk */
47 greg 3.21 off_t fo; /* position in file */
48 gregl 3.1 } BEAMI; /* beam index */
49    
50     typedef struct {
51 greg 3.22 uint32 nrm; /* number of beam rays bundled in memory */
52 gregl 3.1 unsigned long tick; /* clock tick for LRU replacement */
53     } BEAM; /* followed by nrm RAYVAL's */
54    
55 gregl 3.3 #define hdbray(bp) ((RAYVAL *)((bp)+1))
56 gregl 3.1 #define hdbsiz(nr) (sizeof(BEAM)+(nr)*sizeof(RAYVAL))
57    
58     typedef struct {
59     FVECT orig; /* prism origin (first) */
60     FVECT xv[3]; /* side vectors (second) */
61 greg 3.22 int16 grid[3]; /* grid resolution (third) */
62 gregl 3.1 } HDGRID; /* holodeck section grid (must match HOLO struct) */
63    
64     typedef struct holo {
65     FVECT orig; /* prism origin (first) */
66     FVECT xv[3]; /* side vectors (second) */
67 greg 3.22 int16 grid[3]; /* grid resolution (third) */
68 gregl 3.1 int fd; /* file descriptor */
69 gwlarson 3.17 struct {
70     int s, n; /* dirty section start, length */
71     } dirseg[MAXDIRSE+1]; /* dirty beam index segments */
72     short dirty; /* number of dirty segments */
73 gregl 3.1 double tlin; /* linear range for depth encoding */
74 gregl 3.13 FVECT wg[3]; /* wall grid vectors (derived) */
75 gregl 3.1 int wi[6]; /* wall super-indices (derived) */
76     char *priv; /* pointer to private client data */
77     BEAM **bl; /* beam pointers (memory cache) */
78     BEAMI bi[1]; /* beam index (extends struct) */
79     } HOLO; /* holodeck section */
80    
81 gregl 3.9 typedef struct {
82     HOLO *h; /* pointer to holodeck */
83     int b; /* beam index */
84     } HDBEAMI; /* holodeck beam index */
85    
86 gregl 3.14 #define nbeams(hp) (((hp)->wi[5]-1)<<1)
87 gregl 3.1 #define biglob(hp) ((hp)->bi)
88     #define blglob(hp) (*(hp)->bl)
89    
90     #define bnrays(hp,i) ((hp)->bl[i]!=NULL ? (hp)->bl[i]->nrm : (hp)->bi[i].nrd)
91    
92 gwlarson 3.16 #define hdflush(hp) (hdfreebeam(hp,0), hdsync(hp,0))
93     #define hdclobber(hp) (hdkillbeam(hp,0), hdsync(hp,0))
94 gregl 3.1
95 gregl 3.4 extern HOLO *hdinit(), *hdalloc();
96 gregl 3.1 extern BEAM *hdgetbeam();
97     extern RAYVAL *hdnewrays();
98 gregl 3.9 extern unsigned hdmemuse();
99 greg 3.21 extern off_t hdfiluse(), hdfilen(), hdallocfrag();
100 gregl 3.1 extern double hdray(), hdinter();
101     extern unsigned hdcode();
102 gregl 3.14 extern int hdfilord();
103 gregl 3.1
104 gwlarson 3.19 #define FF_NEVER 0 /* never free fragments */
105     #define FF_WRITE 01 /* free fragment on write */
106     #define FF_ALLOC 02 /* free fragment on ray alloc */
107     #define FF_READ 04 /* free fragment on read */
108     #define FF_KILL 010 /* free fragment on beam kill */
109    
110     extern int hdfragflags; /* tells when to free fragments */
111 gregl 3.9 extern unsigned hdcachesize; /* target cache size (bytes) */
112 gregl 3.1 extern unsigned long hdclock; /* holodeck system clock */
113     extern HOLO *hdlist[HDMAX+1]; /* holodeck pointers (NULL term.) */
114    
115     extern float hd_depthmap[]; /* depth conversion map */
116 gregl 3.13
117     extern int hdwg0[6]; /* wall grid 0 index */
118     extern int hdwg1[6]; /* wall grid 1 index */
119 gregl 3.1
120     #define hddepth(hp,dc) ( (dc) >= DCINF ? FHUGE : \
121     (hp)->tlin * ( (dc) >= DCLIN ? \
122     hd_depthmap[(dc)-DCLIN] : \
123     ((dc)+.5)/DCLIN ) )
124    
125     #define HOLOFMT "Holodeck" /* file format identifier */
126     #define HOLOVERS 0 /* file format version number */
127 greg 3.21 #define HOLOMAGIC (323+sizeof(off_t)+8*HOLOVERS) /* file magic number */
128 gregl 3.1
129     /*
130     * A holodeck file consists of an information header terminated by a
131     * blank line, with "FORMAT=Holodeck" somewhere in it.
132     * The first integer after the information header is the
133     * above magic number, which includes the file format version number.
134 gregl 3.6 * The first longword after the magic number is a pointer to the pointer
135     * just before the SECOND holodeck section, or 0 if there is only one.
136 gregl 3.1 * This longword is immediately followed by the first holodeck
137     * section header and directory.
138     * Similarly, every holodeck section in the file is preceeded by
139     * a pointer to the following section, or 0 for the final section.
140     * Since holodeck files consist of directly written C data structures,
141     * they are not generally portable between different machine architectures.
142     * In particular, different floating point formats or bit/byte ordering
143     * will make the data unusable. This is unfortunate, and may be changed
144     * in future versions, but we thought this would be best for paging speed
145     * in our initial implementation.
146     */