UFO: Alien Invasion
Loading...
Searching...
No Matches
bsp.h
Go to the documentation of this file.
1
4
5/*
6Copyright (C) 1997-2001 Id Software, Inc.
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23*/
24
25#pragma once
26
27#include <assert.h>
28
29#include "map.h"
30#include "bspbrush.h"
31
32#include "common/shared.h"
33#include "common/scriplib.h"
34#include "common/polylib.h"
35#include "common/bspfile.h"
36
38
39extern dMapTile_t* curTile;
40extern mapTiles_t mapTiles;
41
42typedef struct node_s {
44 int32_t planenum;
45 struct node_s* parent;
48
51 struct node_s* children[2];
53
56 int32_t contentFlags;
57 int area;
58 struct portal_s* portals;
59} node_t;
60
61typedef struct tree_s {
62 struct node_s* headnode;
63 struct node_s outside_node;
65} tree_t;
66
68extern int nummapplanes;
69
70extern int nummapbrushes;
72
73extern int nummapbrushsides;
76
78
79byte GetLevelFlagsFromBrush(const mapbrush_t* brush);
80void LoadMapFile(const char* filename);
81void WriteMapFile(const char* filename);
82uint16_t FindOrCreateFloatPlane(vec3_t normal, vec_t dist);
83
84/*============================================================================= */
85
86/* csg.c */
87int MapBrushesBounds(const int startbrush, const int endbrush, const int level, const AABB& clipBox, AABB& bBox);
88bspbrush_t* MakeBspBrushList(int startbrush, int endbrush, int level, const AABB& clip);
90
91/* portals.c */
92uint32_t VisibleContents(uint32_t contents);
93void MarkVisibleSides(tree_t* tree, int start, int end);
94void FreePortal(portal_t* p);
95void MakeTreePortals(tree_t* tree);
96void RemovePortalFromNode(portal_t* portal, node_t* l);
97
98/*============================================================================= */
99
100/* writebsp.c */
101void SetModelNumbers(void);
102
103void BeginBSPFile(void);
104int WriteBSP(node_t* headnode);
105void EndBSPFile(const char* filename);
106void BeginModel(int entityNum);
107void EndModel(void);
108void EmitBrushes(void);
109void EmitPlanes(void);
110
111/* faces.c */
112void MakeFaces(node_t* headnode);
113void FixTjuncs(node_t* headnode);
114int GetEdge(int v1, int v2, const face_t* f);
115void FreeFace(face_t* f);
116
117/* tree.c */
118node_t* AllocNode(void);
119tree_t* AllocTree(void);
120tree_t* BuildTree(bspbrush_t* brushlist, const vec3_t mins, const vec3_t maxs);
121void FreeTree(tree_t* tree);
122void PruneNodes(node_t* node);
123
124/* trace.c */
125void MakeTracingNodes(int levels);
126void CloseTracingNodes(void);
127
128/* routing.c */
129void DoRouting(void);
130
131/* bsp.c */
132void ProcessModels(const char* filename);
int brush_start
Definition levels.cpp:29
void FreeTree(tree_t *tree)
Definition tree.cpp:102
int brush_end
Definition bsp.h:77
void FreePortal(portal_t *p)
Definition portals.cpp:52
void MarkVisibleSides(tree_t *tree, int start, int end)
Definition portals.cpp:482
void MakeFaces(node_t *headnode)
Definition faces.cpp:764
void EmitBrushes(void)
Writes the brush list to the bsp.
Definition writebsp.cpp:236
bspbrush_t * ChopBrushes(bspbrush_t *head)
Carves any intersecting solid brushes into the minimum number of non-intersecting brushes.
Definition csg.cpp:376
side_t brushsides[MAX_MAP_SIDES]
Definition map.cpp:37
void RemovePortalFromNode(portal_t *portal, node_t *l)
Removes references to the given portal from the given node.
Definition portals.cpp:102
byte GetLevelFlagsFromBrush(const mapbrush_t *brush)
Extract the level flags (1-8) from the content flags of the given brush.
Definition map.cpp:277
int nummapbrushsides
Definition map.cpp:38
bspbrush_t * MakeBspBrushList(int startbrush, int endbrush, int level, const AABB &clip)
Definition csg.cpp:292
void EndBSPFile(const char *filename)
Finishes a new bsp and writes to disk.
Definition writebsp.cpp:336
void EndModel(void)
Finish a model's processing.
Definition writebsp.cpp:387
int GetEdge(int v1, int v2, const face_t *f)
Definition faces.cpp:399
void MakeTreePortals(tree_t *tree)
Definition portals.cpp:391
void BeginBSPFile(void)
Starts a new bsp file.
Definition writebsp.cpp:303
void CloseTracingNodes(void)
Definition trace.cpp:65
void FixTjuncs(node_t *headnode)
Definition faces.cpp:370
int MapBrushesBounds(const int startbrush, const int endbrush, const int level, const AABB &clipBox, AABB &bBox)
sets mins and maxs to the smallest sizes that can contain all brushes from startbrush to endbrush tha...
Definition csg.cpp:264
tree_t * BuildTree(bspbrush_t *brushlist, const vec3_t mins, const vec3_t maxs)
The incoming list will be freed before exiting.
Definition tree.cpp:182
int nummapbrushes
Definition map.cpp:35
int nummapplanes
Definition map.cpp:44
brush_texture_t side_brushtextures[MAX_MAP_SIDES]
Definition map.cpp:40
plane_t mapplanes[MAX_MAP_PLANES]
Definition map.cpp:43
void PruneNodes(node_t *node)
Definition tree.cpp:261
void WriteMapFile(const char *filename)
Definition map.cpp:1055
uint16_t FindOrCreateFloatPlane(vec3_t normal, vec_t dist)
Definition map.cpp:194
tree_t * AllocTree(void)
Allocates a tree and initializes it.
Definition tree.cpp:92
void FreeFace(face_t *f)
Definition faces.cpp:133
mapbrush_t mapbrushes[MAX_MAP_BRUSHES]
Definition map.cpp:34
int WriteBSP(node_t *headnode)
copies working data for a bsp tree into the structures used to create the bsp file.
Definition writebsp.cpp:195
node_t * AllocNode(void)
Definition tree.cpp:34
uint32_t VisibleContents(uint32_t contents)
Returns the single content bit of the strongest visible content present.
Definition portals.cpp:64
void ProcessModels(const char *filename)
Definition bsp.cpp:106
void LoadMapFile(const char *filename)
Definition map.cpp:1197
void EmitPlanes(void)
Emits planes to the bsp file.
Definition writebsp.cpp:41
void MakeTracingNodes(int levels)
Use the bsp node structure to reconstruct efficient tracing structures that are used for fast visibil...
Definition trace.cpp:38
void BeginModel(int entityNum)
Sets up a new brush model.
Definition writebsp.cpp:353
void SetModelNumbers(void)
Set the model numbers for SOLID_BSP or SOLID_TRIGGER entities like func_door or func_breakable.
Definition writebsp.cpp:217
void DoRouting(void)
Calculates the routing of a map.
Definition routing.cpp:115
Definition aabb.h:42
#define MAX_MAP_SIDES
Definition defines.h:383
#define MAX_MAP_BRUSHES
Definition defines.h:135
#define MAX_MAP_PLANES
Definition defines.h:139
level_locals_t level
Definition g_main.cpp:38
const char * filename
Definition ioapi.h:41
static int entityNum
Definition levels.cpp:220
QGL_EXTERN GLfloat f
Definition r_gl.h:114
Definition map.h:42
Definition bsp.h:42
int32_t planenum
Definition bsp.h:44
AABB nBox
Definition bsp.h:46
struct node_s * parent
Definition bsp.h:45
int32_t contentFlags
Definition bsp.h:56
int area
Definition bsp.h:57
bspbrush_t * brushlist
Definition bsp.h:55
side_t * side
Definition bsp.h:50
face_t * faces
Definition bsp.h:52
struct portal_s * portals
Definition bsp.h:58
bspbrush_t * volume
Definition bsp.h:47
struct node_s * children[2]
Definition bsp.h:51
Definition map.h:98
Definition map.h:60
Definition bsp.h:61
struct node_s * headnode
Definition bsp.h:62
struct node_s outside_node
Definition bsp.h:63
AABB aabb
Definition bsp.h:64
static mapTiles_t mapTiles
dMapTile_t * curTile
Definition bsp.cpp:32
Tracing functions.
float vec_t
Definition ufotypes.h:37
vec_t vec3_t[3]
Definition ufotypes.h:39