1 /*
2 Copyright (C) 1997-2001 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 // cm_common.h
22 //
23 
24 #include "common.h"
25 
26 #define MAX_CM_CMODELS		1024		// Must be >= Q2BSP_MAX_MODELS and >= Q3BSP_MAX_MODELS
27 
28 typedef struct cBspModel_s {
29 	vec3_t					mins;
30 	vec3_t					maxs;
31 
32 	int						headNode;
33 
34 	// Q3BSP
35 	int						nummarkfaces;
36 	struct cQ3BspFace_s		**markfaces;
37 
38 	int						nummarkbrushes;
39 	struct cQ3BspBrush_s	**markbrushes;
40 	// !Q3BSP
41 } cBspModel_t;
42 
43 extern int					cm_numCModels;
44 extern cBspModel_t			cm_mapCModels[MAX_CM_CMODELS];
45 
46 extern int					cm_numTraces;
47 extern int					cm_numBrushTraces;
48 extern int					cm_numPointContents;
49 
50 extern cVar_t				*flushmap;
51 extern cVar_t				*cm_noAreas;
52 extern cVar_t				*cm_noCurves;
53 extern cVar_t				*cm_showTrace;
54 
55 /*
56 =============================================================================
57 
58 	QUAKE2 BSP
59 
60 =============================================================================
61 */
62 
63 cBspModel_t	*CM_Q2BSP_LoadMap (uint32 *buffer);
64 void		CM_Q2BSP_PrepMap (void);
65 void		CM_Q2BSP_UnloadMap (void);
66 
67 char		*CM_Q2BSP_EntityString (void);
68 char		*CM_Q2BSP_SurfRName (int texNum);
69 int			CM_Q2BSP_NumClusters (void);
70 int			CM_Q2BSP_NumTexInfo (void);
71 
72 // ==========================================================================
73 
74 int			CM_Q2BSP_LeafArea (int leafNum);
75 int			CM_Q2BSP_LeafCluster (int leafNum);
76 int			CM_Q2BSP_LeafContents (int leafNum);
77 
78 int			CM_Q2BSP_HeadnodeForBox (vec3_t mins, vec3_t maxs);
79 int			CM_Q2BSP_PointLeafnum (vec3_t p);
80 int			CM_Q2BSP_BoxLeafnums (vec3_t mins, vec3_t maxs, int *list, int listSize, int *topNode);
81 
82 int			CM_Q2BSP_PointContents (vec3_t p, int headNode);
83 int			CM_Q2BSP_TransformedPointContents (vec3_t p, int headNode, vec3_t origin, vec3_t angles);
84 
85 trace_t		CM_Q2BSP_Trace (vec3_t start, vec3_t end, float size, int contentMask);
86 trace_t		CM_Q2BSP_BoxTrace (vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int headNode, int brushMask);
87 void		CM_Q2BSP_TransformedBoxTrace (trace_t *out, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int headNode, int brushMask, vec3_t origin, vec3_t angles);
88 
89 byte		*CM_Q2BSP_ClusterPVS (int cluster);
90 byte		*CM_Q2BSP_ClusterPHS (int cluster);
91 
92 void		CM_Q2BSP_SetAreaPortalState (int portalNum, qBool open);
93 qBool		CM_Q2BSP_AreasConnected (int area1, int area2);
94 int			CM_Q2BSP_WriteAreaBits (byte *buffer, int area);
95 void		CM_Q2BSP_WritePortalState (fileHandle_t fileNum);
96 void		CM_Q2BSP_ReadPortalState (fileHandle_t fileNum);
97 qBool		CM_Q2BSP_HeadnodeVisible (int nodeNum, byte *visBits);
98 
99 /*
100 =============================================================================
101 
102 	QUAKE3 BSP
103 
104 =============================================================================
105 */
106 
107 cBspModel_t	*CM_Q3BSP_LoadMap (uint32 *buffer);
108 void		CM_Q3BSP_PrepMap (void);
109 void		CM_Q3BSP_UnloadMap (void);
110 
111 char		*CM_Q3BSP_EntityString (void);
112 char		*CM_Q3BSP_SurfRName (int texNum);
113 int			CM_Q3BSP_NumClusters (void);
114 int			CM_Q3BSP_NumTexInfo (void);
115 
116 // ==========================================================================
117 
118 int			CM_Q3BSP_LeafArea (int leafNum);
119 int			CM_Q3BSP_LeafCluster (int leafNum);
120 int			CM_Q3BSP_LeafContents (int leafNum);
121 
122 int			CM_Q3BSP_HeadnodeForBox (vec3_t mins, vec3_t maxs);
123 int			CM_Q3BSP_PointLeafnum (vec3_t p);
124 int			CM_Q3BSP_BoxLeafnums (vec3_t mins, vec3_t maxs, int *list, int listSize, int *topNode);
125 
126 int			CM_Q3BSP_PointContents (vec3_t p, int headNode);
127 int			CM_Q3BSP_TransformedPointContents (vec3_t p, int headNode, vec3_t origin, vec3_t angles);
128 
129 trace_t		CM_Q3BSP_Trace (vec3_t start, vec3_t end, float size, int contentMask);
130 trace_t		CM_Q3BSP_BoxTrace (vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int headNode, int brushMask);
131 void		CM_Q3BSP_TransformedBoxTrace (trace_t *out, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int headNode, int brushMask, vec3_t origin, vec3_t angles);
132 
133 byte		*CM_Q3BSP_ClusterPVS (int cluster);
134 byte		*CM_Q3BSP_ClusterPHS (int cluster);
135 
136 void		CM_Q3BSP_SetAreaPortalState (int portalNum, int area, int otherArea, qBool open);
137 qBool		CM_Q3BSP_AreasConnected (int area1, int area2);
138 int			CM_Q3BSP_WriteAreaBits (byte *buffer, int area);
139 void		CM_Q3BSP_WritePortalState (fileHandle_t fileNum);
140 void		CM_Q3BSP_ReadPortalState (fileHandle_t fileNum);
141 qBool		CM_Q3BSP_HeadnodeVisible (int nodeNum, byte *visBits);
142