1 /*
2 This program is free software; you can redistribute it and/or
3 modify it under the terms of the GNU General Public License
4 as published by the Free Software Foundation; either version 2
5 of the License, or (at your option) any later version.
6 
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 
11 See the GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 
17 
18 */
19 
20 // cmodel.h
21 #ifndef __CMODEL_H__
22 #define __CMODEL_H__
23 
24 #include "bspfile.h"
25 
26 // mplane->type
27 enum {
28 	SIDE_FRONT = 0,
29 	SIDE_BACK = 1,
30 	SIDE_ON = 2
31 };
32 
33 
34 // plane_t structure
35 // !!! if this is changed, it must be changed in asm_i386.h too !!!
36 typedef struct mplane_s {
37 	vec3_t	normal;
38 	float	dist;
39 	byte	type;			// for texture axis selection and fast side tests
40 	byte	signbits;		// signx + signy<<1 + signz<<1
41 	byte	pad[2];
42 } mplane_t;
43 
44 // !!! if this is changed, it must be changed in asm_i386.h too !!!
45 typedef struct {
46 	mclipnode_t	*clipnodes;
47 	mplane_t	*planes;
48 	int			firstclipnode;
49 	int			lastclipnode;
50 	vec3_t		clip_mins;
51 	vec3_t		clip_maxs;
52 } hull_t;
53 
54 typedef struct {
55 	vec3_t	normal;
56 	float	dist;
57 } plane_t;
58 
59 typedef struct mphysicsnormal_s {
60 	vec3_t             normal;
61 	int                flags;
62 } mphysicsnormal_t;
63 
64 #define PHYSICSNORMAL_SET      1
65 #define PHYSICSNORMAL_FLIPX    2
66 #define PHYSICSNORMAL_FLIPY    4
67 #define PHYSICSNORMAL_FLIPZ    8
68 
69 mphysicsnormal_t CM_PhysicsNormal(int num);
70 #ifndef SERVER_ONLY
71 void CM_PhysicsNormalSet(int num, float x, float y, float z, int flags);
72 void CM_PhysicsNormalDump(FILE* out, float rampjump, float maxgroundspeed);
73 #endif
74 
75 typedef struct {
76 	qbool   allsolid;           // if true, plane is not valid
77 	qbool   startsolid;         // if true, the initial point was in a solid area
78 	qbool   inopen, inwater;
79 	float   fraction;           // time completed, 1.0 = didn't hit anything
80 	vec3_t  endpos;             // final position
81 	plane_t plane;              // surface normal at impact
82 	int     physicsnormal;      // surface normal for physics
83 	union {                     // entity the surface is on
84 		int entnum;             // for pmove
85 		struct edict_s *ent;    // for sv_world
86 	} e;
87 } trace_t;
88 
89 typedef struct {
90 	vec3_t	mins, maxs;
91 	vec3_t	origin;
92 	hull_t	hulls[MAX_MAP_HULLS];
93 } cmodel_t;
94 
95 hull_t *CM_HullForBox (vec3_t mins, vec3_t maxs);
96 int CM_HullPointContents (hull_t *hull, int num, vec3_t p);
97 int CM_CachedHullPointContents(hull_t* hull, int num, vec3_t p, float* min_dist);
98 trace_t CM_HullTrace (hull_t *hull, vec3_t start, vec3_t end);
99 struct cleaf_s *CM_PointInLeaf (const vec3_t p);
100 int CM_Leafnum (const struct cleaf_s *leaf);
101 int CM_LeafAmbientLevel (const struct cleaf_s *leaf, int ambient_channel);
102 byte *CM_LeafPVS (const struct cleaf_s *leaf);
103 byte *CM_LeafPHS (const struct cleaf_s *leaf); // only for the server
104 byte *CM_FatPVS (vec3_t org);
105 int CM_FindTouchedLeafs (const vec3_t mins, const vec3_t maxs, int leafs[], int maxleafs, int headnode, int *topnode);
106 char *CM_EntityString (void);
107 int CM_NumInlineModels (void);
108 cmodel_t *CM_InlineModel (char *name);
109 void CM_InvalidateMap (void);
110 cmodel_t *CM_LoadMap (char *name, qbool clientload, unsigned *checksum, unsigned *checksum2);
111 void CM_Init (void);
112 
113 typedef struct bspx_header_s {
114 	char id[4];  // 'BSPX'
115 	int numlumps;
116 } bspx_header_t;
117 
118 void* Mod_BSPX_FindLump(bspx_header_t* bspx_header, char* lumpname, int* plumpsize, byte* mod_base);
119 bspx_header_t* Mod_LoadBSPX(int filesize, byte* mod_base);
120 
121 #endif /* !__CMODEL_H__ */
122