]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - model_brush.h
optimized AngleVectors calls (pass NULL for vectors that should not be generated)
[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         rtexture_t      *texture;
59         rtexture_t      *glowtexture; // 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 // LordHavoc: light both sides
81 #define SURF_LIGHTBOTHSIDES             0x400
82
83 // !!! if this is changed, it must be changed in asm_draw.h too !!!
84 typedef struct
85 {
86         unsigned short  v[2];
87         unsigned int    cachededgeoffset;
88 } medge_t;
89
90 typedef struct
91 {
92         float           vecs[2][4];
93         float           mipadjust;
94         texture_t       *texture;
95         int                     flags;
96 } mtexinfo_t;
97
98 // LordHavoc: was 7, I added one more for raw lightmap position
99 #define VERTEXSIZE      8
100
101 typedef struct glpoly_s
102 {
103         struct  glpoly_s        *next;
104         struct  glpoly_s        *chain;
105         int             numverts;
106         int             flags;                  // for SURF_UNDERWATER
107         float   verts[4][VERTEXSIZE];   // variable sized (xyz s1t1 s2t2)
108 } glpoly_t;
109
110 typedef struct msurface_s
111 {
112         int                     visframe;               // should be drawn when node is crossed
113
114         mplane_t        *plane;
115         int                     flags;
116
117         int                     firstedge;      // look up in model->surfedges[], negative numbers
118         int                     numedges;       // are backwards edges
119         
120         short           texturemins[2];
121         short           extents[2];
122
123         short           light_s, light_t;       // gl lightmap coordinates
124
125         glpoly_t        *polys;                         // multiple if warped
126         struct  msurface_s      *texturechain;
127
128         mtexinfo_t      *texinfo;
129         
130 // lighting info
131         int                     dlightframe;
132         int                     dlightbits[8];
133
134         int                     lightframe; // avoid redundent addition of dlights
135         int                     worldnodeframe; // only render each surface once
136
137         int                     lightmaptexturenum;
138         byte            styles[MAXLIGHTMAPS];
139         unsigned short  cached_light[MAXLIGHTMAPS];     // values currently used in lightmap
140         short           cached_dlight;                          // LordHavoc: if lightmap was lit by dynamic lights, update on frame after end of effect to erase it
141         short           cached_lighthalf;                       // LordHavoc: to cause lightmap to be rerendered when lighthalf changes
142         float           cached_ambient;                         // LordHavoc: rerender lightmaps when r_ambient changes
143         byte            *samples;               // [numstyles*surfsize]
144 } msurface_t;
145
146 // warning: if this is changed, references must be updated in cpu_* assembly files
147 typedef struct mnode_s
148 {
149 // common with leaf
150         int                     contents;               // 0, to differentiate from leafs
151         int                     visframe;               // node needs to be traversed if current
152         int                     lightframe;             // LordHavoc: to avoid redundent parent chasing in R_VisMarkLights
153         
154         float           minmaxs[6];             // for bounding box culling
155
156         struct mnode_s  *parent;
157
158         // LordHavoc: node based dynamic lighting
159         int                     dlightbits[8];
160         int                     dlightframe;
161
162 // node specific
163         mplane_t        *plane;
164         struct mnode_s  *children[2];   
165
166         unsigned short          firstsurface;
167         unsigned short          numsurfaces;
168 } mnode_t;
169
170
171
172 typedef struct mleaf_s
173 {
174 // common with node
175         int                     contents;               // wil be a negative contents number
176         int                     visframe;               // node needs to be traversed if current
177         int                     lightframe;             // LordHavoc: to avoid redundent parent chasing in R_VisMarkLights
178
179         float           minmaxs[6];             // for bounding box culling
180
181         struct mnode_s  *parent;
182
183         // LordHavoc: node based dynamic lighting
184         int                     dlightbits[8];
185         int                     dlightframe;
186
187 // leaf specific
188         byte            *compressed_vis;
189         efrag_t         *efrags;
190
191         msurface_t      **firstmarksurface;
192         int                     nummarksurfaces;
193         int                     key;                    // BSP sequence number for leaf's contents
194         byte            ambient_sound_level[NUM_AMBIENTS];
195 } mleaf_t;
196
197 typedef struct
198 {
199         dclipnode_t     *clipnodes;
200         mplane_t        *planes;
201         int                     firstclipnode;
202         int                     lastclipnode;
203         vec3_t          clip_mins;
204         vec3_t          clip_maxs;
205 } hull_t;