]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - model_brush.h
172ae413a927bad33be27b3a85d716d244023a84
[xonotic/darkplaces.git] / model_brush.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 /*
22 ==============================================================================
23
24 BRUSH MODELS
25
26 ==============================================================================
27 */
28
29
30 //
31 // in memory representation
32 //
33 // !!! if this is changed, it must be changed in asm_draw.h too !!!
34 typedef struct
35 {
36         vec3_t          position;
37 } mvertex_t;
38
39 #define SIDE_FRONT      0
40 #define SIDE_BACK       1
41 #define SIDE_ON         2
42
43
44 // plane_t structure
45 typedef struct mplane_s
46 {
47         vec3_t  normal;
48         float   dist;
49         byte    type;                   // for texture axis selection and fast side tests
50         byte    pad[3];
51         int (*BoxOnPlaneSideFunc) (vec3_t emins, vec3_t emaxs, struct mplane_s *p);
52 } mplane_t;
53
54 typedef struct texture_s
55 {
56         char            name[16];
57         unsigned        width, height;
58         int                     gl_texturenum;
59         int                     gl_glowtexturenum; // LordHavoc: fullbrights on walls
60         struct msurface_s       *texturechain;  // for gl_texsort drawing
61         int                     anim_total;                             // total tenths in sequence ( 0 = no)
62         int                     anim_min, anim_max;             // time for this frame min <=time< max
63         struct texture_s *anim_next;            // in the animation sequence
64         struct texture_s *alternate_anims;      // bmodels in frame 1 use these
65         unsigned        offsets[MIPLEVELS];             // four mip maps stored
66         int                     transparent;    // LordHavoc: transparent texture support
67 } texture_t;
68
69
70 #define SURF_PLANEBACK          2
71 #define SURF_DRAWSKY            4
72 #define SURF_DRAWSPRITE         8
73 #define SURF_DRAWTURB           0x10
74 #define SURF_DRAWTILED          0x20
75 #define SURF_DRAWBACKGROUND     0x40
76 //#define SURF_UNDERWATER               0x80
77 // LordHavoc: added these for lava and teleport textures
78 #define SURF_DRAWNOALPHA        0x100
79 #define SURF_DRAWFULLBRIGHT     0x200
80
81 // !!! if this is changed, it must be changed in asm_draw.h too !!!
82 typedef struct
83 {
84         unsigned short  v[2];
85         unsigned int    cachededgeoffset;
86 } medge_t;
87
88 typedef struct
89 {
90         float           vecs[2][4];
91         float           mipadjust;
92         texture_t       *texture;
93         int                     flags;
94 } mtexinfo_t;
95
96 // LordHavoc: was 7, I added one more for raw lightmap position
97 #define VERTEXSIZE      8
98
99 typedef struct glpoly_s
100 {
101         struct  glpoly_s        *next;
102         struct  glpoly_s        *chain;
103         int             numverts;
104         int             flags;                  // for SURF_UNDERWATER
105         float   verts[4][VERTEXSIZE];   // variable sized (xyz s1t1 s2t2)
106 } glpoly_t;
107
108 typedef struct msurface_s
109 {
110         int                     visframe;               // should be drawn when node is crossed
111
112         mplane_t        *plane;
113         int                     flags;
114
115         int                     firstedge;      // look up in model->surfedges[], negative numbers
116         int                     numedges;       // are backwards edges
117         
118         short           texturemins[2];
119         short           extents[2];
120
121         short           light_s, light_t;       // gl lightmap coordinates
122
123         glpoly_t        *polys;                         // multiple if warped
124         struct  msurface_s      *texturechain;
125
126         mtexinfo_t      *texinfo;
127         
128 // lighting info
129         int                     dlightframe;
130         int                     dlightbits[8];
131
132         int                     lightframe; // avoid redundent addition of dlights
133         int                     worldnodeframe; // only render each surface once
134
135         int                     lightmaptexturenum;
136         byte            styles[MAXLIGHTMAPS];
137         unsigned short  cached_light[MAXLIGHTMAPS];     // values currently used in lightmap
138         int                     cached_lighthalf;                       // LordHavoc: to cause lightmap to be rerendered when lighthalf changes
139         float           cached_ambient;                         // LordHavoc: rerender lightmaps when r_ambient changes
140         byte            *samples;               // [numstyles*surfsize]
141 } msurface_t;
142
143 // warning: if this is changed, references must be updated in cpu_* assembly files
144 typedef struct mnode_s
145 {
146 // common with leaf
147         int                     contents;               // 0, to differentiate from leafs
148         int                     visframe;               // node needs to be traversed if current
149         int                     lightframe;             // LordHavoc: to avoid redundent parent chasing in R_VisMarkLights
150         
151         float           minmaxs[6];             // for bounding box culling
152
153         struct mnode_s  *parent;
154
155         // LordHavoc: node based dynamic lighting
156         int                     dlightbits[8];
157         int                     dlightframe;
158
159 // node specific
160         mplane_t        *plane;
161         struct mnode_s  *children[2];   
162
163         unsigned short          firstsurface;
164         unsigned short          numsurfaces;
165 } mnode_t;
166
167
168
169 typedef struct mleaf_s
170 {
171 // common with node
172         int                     contents;               // wil be a negative contents number
173         int                     visframe;               // node needs to be traversed if current
174         int                     lightframe;             // LordHavoc: to avoid redundent parent chasing in R_VisMarkLights
175
176         float           minmaxs[6];             // for bounding box culling
177
178         struct mnode_s  *parent;
179
180         // LordHavoc: node based dynamic lighting
181         int                     dlightbits[8];
182         int                     dlightframe;
183
184 // leaf specific
185         byte            *compressed_vis;
186         efrag_t         *efrags;
187
188         msurface_t      **firstmarksurface;
189         int                     nummarksurfaces;
190         int                     key;                    // BSP sequence number for leaf's contents
191         byte            ambient_sound_level[NUM_AMBIENTS];
192 } mleaf_t;
193
194 typedef struct
195 {
196         dclipnode_t     *clipnodes;
197         mplane_t        *planes;
198         int                     firstclipnode;
199         int                     lastclipnode;
200         vec3_t          clip_mins;
201         vec3_t          clip_maxs;
202 } hull_t;