Initial sauer
[SauerbratenRemote.git] / src / engine / world.h
blobf1e82cc15968740ff326c865a8dda447d5024575
2 enum // hardcoded texture numbers
4 DEFAULT_SKY = 0,
5 DEFAULT_LIQUID,
6 DEFAULT_WALL,
7 DEFAULT_FLOOR,
8 DEFAULT_CEIL
9 };
11 #define MAPVERSION 24 // bump if map format changes, see worldio.cpp
13 struct header // map file format header
15 char head[4]; // "OCTA"
16 int version; // any >8bit quantity is little endian
17 int headersize; // sizeof(header)
18 int worldsize;
19 int numents;
20 int waterlevel;
21 int lightmaps;
22 int mapprec, maple, mapllod;
23 uchar ambient;
24 uchar watercolour[3];
25 uchar mapwlod;
26 uchar lerpangle, lerpsubdiv, lerpsubdivsize;
27 uchar mapbe;
28 uchar skylight[3];
29 uchar lavacolour[3];
30 uchar reserved[1+12];
31 char maptitle[128];
34 enum // cube empty-space materials
36 MAT_AIR = 0, // the default, fill the empty space with air
37 MAT_WATER, // fill with water, showing waves at the surface
38 MAT_CLIP, // collisions always treat cube as solid
39 MAT_GLASS, // behaves like clip but is blended blueish
40 MAT_NOCLIP, // collisions always treat cube as empty
41 MAT_LAVA, // fill with lava
42 MAT_AICLIP, // clip monsters only
43 MAT_EDIT // basis for the edit volumes of the above materials
46 #define WATER_AMPLITUDE 0.8f
47 #define WATER_OFFSET 1.1f
49 enum
51 MATSURF_NOT_VISIBLE = 0,
52 MATSURF_VISIBLE,
53 MATSURF_EDIT_ONLY
56 #define isliquid(mat) ((mat)==MAT_WATER || (mat)==MAT_LAVA)
57 #define isclipped(mat) ((mat) >= MAT_CLIP && (mat) < MAT_NOCLIP)
59 // VVEC_FRAC must be between 0..3
60 #define VVEC_FRAC 1
61 #define VVEC_INT (15-VVEC_FRAC)
62 #define VVEC_BITS (VVEC_INT + VVEC_FRAC)
64 #define VVEC_INT_MASK ((1<<(VVEC_INT-1))-1)
65 #define VVEC_INT_COORD(n) (((n)&VVEC_INT_MASK)<<VVEC_FRAC)
67 struct vvec : svec
69 vvec() {}
70 vvec(short x, short y, short z) : svec(x, y, z) {}
71 vvec(int x, int y, int z) : svec(VVEC_INT_COORD(x), VVEC_INT_COORD(y), VVEC_INT_COORD(z)) {}
72 vvec(const int *i) : svec(VVEC_INT_COORD(i[0]), VVEC_INT_COORD(i[1]), VVEC_INT_COORD(i[2])) {}
74 void mask(int f) { f <<= VVEC_FRAC; f |= (1<<VVEC_FRAC)-1; x &= f; y &= f; z &= f; }
76 ivec toivec() const { return ivec(x, y, z).div(1<<VVEC_FRAC); }
77 ivec toivec(int x, int y, int z) const { ivec t = toivec(); t.x += x&~VVEC_INT_MASK; t.y += y&~VVEC_INT_MASK; t.z += z&~VVEC_INT_MASK; return t; }
78 ivec toivec(const ivec &o) const { return toivec(o.x, o.y, o.z); }
80 vec tovec() const { return vec(x, y, z).div(1<<VVEC_FRAC); }
81 vec tovec(int x, int y, int z) const { vec t = tovec(); t.x += x&~VVEC_INT_MASK; t.y += y&~VVEC_INT_MASK; t.z += z&~VVEC_INT_MASK; return t; }
82 vec tovec(const ivec &o) const { return tovec(o.x, o.y, o.z); }
85 struct vertexffc : vvec {};
86 struct fvertexffc : vec {};
87 struct vertexff : vertexffc { short u, v; };
88 struct fvertexff : fvertexffc { short u, v; };
89 struct vertex : vertexff { bvec n; };
90 struct fvertex : fvertexff { bvec n; };
92 extern int floatvtx;
94 #define VTXSIZE \
95 (renderpath==R_FIXEDFUNCTION ? \
96 (floatvtx ? (nolights ? sizeof(fvertexffc) : sizeof(fvertexff)) : (nolights ? sizeof(vertexffc) : sizeof(vertexff))) : \
97 (floatvtx ? sizeof(fvertex) : sizeof(vertex)))