forked from bnoordhuis/bspc
-
Notifications
You must be signed in to change notification settings - Fork 3
/
map_q2.cpp
167 lines (145 loc) · 4.8 KB
/
map_q2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//===========================================================================
// ANSI, Area Navigational System Interface
// AAS, Area Awareness System
//===========================================================================
#include "local.h"
#include "qbsp.h"
#include "l_mem.h"
#include "botlib/aasfile.h" //aas_bbox_t
#include "aas_store.h" //AAS_MAX_BBOXES
#include "aas_cfg.h"
#include "aas_map.h" //AAS_CreateMapBrushes
#include "l_bsp_q2.h"
#ifdef ME
#define NODESTACKSIZE 1024
int nodestack[NODESTACKSIZE];
int *nodestackptr;
int nodestacksize = 0;
int brushmodelnumbers[MAX_MAPFILE_BRUSHES];
int dbrushleafnums[MAX_MAPFILE_BRUSHES];
int dplanes2mapplanes[MAX_MAPFILE_PLANES];
#endif //ME
//====================================================================
#ifdef ME
#define BBOX_NORMAL_EPSILON 0.0001
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void MarkVisibleBrushSides(mapbrush_t *brush)
{
int n, i, planenum;
side_t *side;
dface_t *face;
//
for (n = 0; n < brush->numsides; n++)
{
side = brush->original_sides + n;
//if this side is a bevel or the leaf number of the brush is unknown
if ((side->flags & SFL_BEVEL) || brush->leafnum < 0)
{
//this side is a valid splitter
side->flags |= SFL_VISIBLE;
continue;
} //end if
//assum this side will not be used as a splitter
side->flags &= ~SFL_VISIBLE;
//check if the side plane is used by a visible face
for (i = 0; i < numfaces; i++)
{
face = &dfaces[i];
planenum = dplanes2mapplanes[face->planenum];
if ((planenum & ~1) == (side->planenum & ~1))
{
//this side is a valid splitter
side->flags |= SFL_VISIBLE;
} //end if
} //end for
} //end for
} //end of the function MarkVisibleBrushSides
#endif //ME
//===================================================================
#ifdef ME //Begin MAP loading from BSP file
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void Q2_SetLeafBrushesModelNumbers(int leafnum, int modelnum)
{
int i, brushnum;
dleaf_t *leaf;
leaf = &dleafs[leafnum];
for (i = 0; i < leaf->numleafbrushes; i++)
{
brushnum = dleafbrushes[leaf->firstleafbrush + i];
brushmodelnumbers[brushnum] = modelnum;
dbrushleafnums[brushnum] = leafnum;
} //end for
} //end of the function Q2_SetLeafBrushesModelNumbers
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void Q2_InitNodeStack(void)
{
nodestackptr = nodestack;
nodestacksize = 0;
} //end of the function Q2_InitNodeStack
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void Q2_PushNodeStack(int num)
{
*nodestackptr = num;
nodestackptr++;
nodestacksize++;
//
if (nodestackptr >= &nodestack[NODESTACKSIZE])
{
Error("Q2_PushNodeStack: stack overflow\n");
} //end if
} //end of the function Q2_PushNodeStack
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int Q2_PopNodeStack(void)
{
//if the stack is empty
if (nodestackptr <= nodestack) return -1;
//decrease stack pointer
nodestackptr--;
nodestacksize--;
//return the top value from the stack
return *nodestackptr;
} //end of the function Q2_PopNodeStack
//End MAP loading from BSP file
#endif //ME