--- ray/src/hd/holo.h 1998/11/09 17:10:53 3.17 +++ ray/src/hd/holo.h 2022/11/16 00:12:49 3.30 @@ -1,16 +1,19 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - -/* SCCSid "$SunId$ SGI" */ - +/* RCSid: $Id: holo.h,v 3.30 2022/11/16 00:12:49 greg Exp $ */ /* * Header file for holodeck programs * * 9/29/97 GWLarson */ +#ifndef _RAD_HOLO_H_ +#define _RAD_HOLO_H_ #include "standard.h" #include "color.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifndef HDMAX #define HDMAX 128 /* maximum active holodeck sections */ #endif @@ -23,9 +26,9 @@ #define DCLIN (unsigned)(1L<<11) /* linear depth limit */ typedef struct { - BYTE r[2][2]; /* ray direction index */ + uby8 r[2][2]; /* ray direction index */ COLR v; /* color value */ - unsigned int2 d; /* depth code (from entry wall) */ + uint16 d; /* depth code (from entry wall) */ } RAYVAL; /* ray value */ /* @@ -46,13 +49,13 @@ typedef struct { } GCOORD; /* grid coordinates (two for beam) */ typedef struct { - unsigned int4 nrd; /* number of beam rays bundled on disk */ - long fo; /* position in file */ + uint32 nrd; /* number of beam rays bundled on disk */ + off_t fo; /* position in file */ } BEAMI; /* beam index */ typedef struct { - unsigned int4 nrm; /* number of beam rays bundled in memory */ - unsigned long tick; /* clock tick for LRU replacement */ + uint32 nrm; /* number of beam rays bundled in memory */ + uint32 tick; /* clock tick for LRU replacement */ } BEAM; /* followed by nrm RAYVAL's */ #define hdbray(bp) ((RAYVAL *)((bp)+1)) @@ -61,13 +64,13 @@ typedef struct { typedef struct { FVECT orig; /* prism origin (first) */ FVECT xv[3]; /* side vectors (second) */ - int2 grid[3]; /* grid resolution (third) */ + int16 grid[3]; /* grid resolution (third) */ } HDGRID; /* holodeck section grid (must match HOLO struct) */ typedef struct holo { FVECT orig; /* prism origin (first) */ FVECT xv[3]; /* side vectors (second) */ - int2 grid[3]; /* grid resolution (third) */ + int16 grid[3]; /* grid resolution (third) */ int fd; /* file descriptor */ struct { int s, n; /* dirty section start, length */ @@ -75,9 +78,8 @@ typedef struct holo { short dirty; /* number of dirty segments */ double tlin; /* linear range for depth encoding */ FVECT wg[3]; /* wall grid vectors (derived) */ - double wo[6]; /* wall grid offsets (derived) */ int wi[6]; /* wall super-indices (derived) */ - char *priv; /* pointer to private client data */ + void *priv; /* pointer to private client data */ BEAM **bl; /* beam pointers (memory cache) */ BEAMI bi[1]; /* beam index (extends struct) */ } HOLO; /* holodeck section */ @@ -96,15 +98,13 @@ typedef struct { #define hdflush(hp) (hdfreebeam(hp,0), hdsync(hp,0)) #define hdclobber(hp) (hdkillbeam(hp,0), hdsync(hp,0)) -extern HOLO *hdinit(), *hdalloc(); -extern BEAM *hdgetbeam(); -extern RAYVAL *hdnewrays(); -extern unsigned hdmemuse(); -extern long hdfiluse(), hdfilen(), hdallocfrag(); -extern double hdray(), hdinter(); -extern unsigned hdcode(); -extern int hdfilord(); +#define FF_NEVER 0 /* never free fragments */ +#define FF_WRITE 01 /* free fragment on write */ +#define FF_ALLOC 02 /* free fragment on ray alloc */ +#define FF_READ 04 /* free fragment on read */ +#define FF_KILL 010 /* free fragment on beam kill */ +extern int hdfragflags; /* tells when to free fragments */ extern unsigned hdcachesize; /* target cache size (bytes) */ extern unsigned long hdclock; /* holodeck system clock */ extern HOLO *hdlist[HDMAX+1]; /* holodeck pointers (NULL term.) */ @@ -121,15 +121,15 @@ extern int hdwg1[6]; /* wall grid 1 index */ #define HOLOFMT "Holodeck" /* file format identifier */ #define HOLOVERS 0 /* file format version number */ -#define HOLOMAGIC (323+sizeof(long)+8*HOLOVERS) /* file magic number */ +#define HOLOMAGIC (324+sizeof(BEAMI)+16*HOLOVERS) /* file magic number */ /* * A holodeck file consists of an information header terminated by a * blank line, with "FORMAT=Holodeck" somewhere in it. * The first integer after the information header is the * above magic number, which includes the file format version number. - * The first longword after the magic number is a pointer to the pointer - * just before the SECOND holodeck section, or 0 if there is only one. + * The first longword (off_t) after the magic number is a pointer to the + * pointer just before the SECOND holodeck section, or 0 if there is only one. * This longword is immediately followed by the first holodeck * section header and directory. * Similarly, every holodeck section in the file is preceeded by @@ -141,3 +141,39 @@ extern int hdwg1[6]; /* wall grid 1 index */ * in future versions, but we thought this would be best for paging speed * in our initial implementation. */ + + /* clumpbeams.c */ +extern void clumpbeams(HOLO *hp, int maxcnt, int maxsiz, + int (*cf)(HOLO *hp, int *bqueue, int bqlen)); + /* holo.c */ +extern void hdcompgrid(HOLO *hp); +extern int hdbcoord(GCOORD gc[2], HOLO *hp, int i); +extern int hdbindex(HOLO *hp, GCOORD gc[2]); +extern void hdcell(FVECT cp[4], HOLO *hp, GCOORD *gc); +extern int hdlseg(int lseg[2][3], HOLO *hp, GCOORD gc[2]); +extern unsigned int hdcode(HOLO *hp, double d); +extern void hdgrid( FVECT gp, HOLO *hp, FVECT wp); +extern void hdworld(FVECT wp, HOLO *hp, FVECT gp); +extern double hdray(FVECT ro, FVECT rd, HOLO *hp, GCOORD gc[2], uby8 r[2][2]); +extern double hdinter(GCOORD gc[2], uby8 r[2][2], double *ed, HOLO *hp, + FVECT ro, FVECT rd); + /* holofile.c */ +extern HOLO * hdinit(int fd, HDGRID *hproto); +extern void hddone(HOLO *hp); +extern int hdsync(HOLO *hp, int all); +extern off_t hdfilen(int fd); +extern off_t hdfiluse(int fd); +extern RAYVAL * hdnewrays(HOLO *hp, int i, int nr); +extern BEAM * hdgetbeam(HOLO *hp, int i); +extern void hdloadbeams(HDBEAMI *hb, int n, void (*bf)(BEAM *bp, HDBEAMI *hb)); +extern int hdfreebeam(HOLO *hp, int i); +extern int hdfreefrag(HOLO *hp, int i); +extern int hdfragOK(int fd, int *listlen, int32 *listsiz); +extern int hdkillbeam(HOLO *hp, int i); + + +#ifdef __cplusplus +} +#endif +#endif /* _RAD_HOLO_H_ */ +