Debian Codegraph @

Descent3/bsp.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * 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, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/bsp.h $
21 * $Revision: 13 $
22 * $Date: 4/19/00 5:30p $
23 * $Author: Matt $
24 *
25 * Header for bsp.cpp
26 *
27 * $Log: /DescentIII/Main/bsp.h $
28 *
29 * 13 4/19/00 5:30p Matt
30 * From Duane for 1.4
31 * Added extern
32 *
33 * 12 4/14/99 3:56a Jeff
34 * fixed case mismatch in #includes
35 *
36 * 11 9/22/98 12:01p Matt
37 * Added SourceSafe headers
38 *
39 */
40
41 #ifndef BSP_H
42 #define BSP_H
43
44 #include "list.h"
45 #include "vecmat.h"
46 #include "cfile.h"
47
48 #define BSP_IN_FRONT 1
49 #define BSP_BEHIND 2
50 #define BSP_ON_PLANE 3
51 #define BSP_SPANNING 4
52 #define BSP_COINCIDENT 5
53
54 #define BSP_EPSILON .00005f
55
56 #define BSP_NODE 0
57 #define BSP_EMPTY_LEAF 1
58 #define BSP_SOLID_LEAF 2
59
60 struct bspplane {
61 float a, b, c, d;
62 uint8_t used;
63 };
64
65 struct bsppolygon {
66 vector *verts;
67 int nv;
68 bspplane plane;
69
70 int16_t roomnum;
71 int16_t facenum;
72 int8_t subnum;
73
74 int color;
75
76 };
77
78 struct bspnode {
79 uint8_t type;
80 bspplane plane;
81 uint16_t node_facenum;
82 uint16_t node_roomnum;
83 int8_t node_subnum;
84
85 bspnode *front;
86 bspnode *back;
87
88 listnode *polylist;
89 int num_polys;
90 };
91
92 struct bsptree {
93 listnode *vertlist;
94 listnode *polylist;
95 bspnode *root;
96 };
97
98 // Builds a bsp tree for the indoor rooms
99 void BuildBSPTree();
100
101 // Runs a ray through the bsp tree
102 // Returns true if a ray is occludes
103 int BSPRayOccluded(vector *start, vector *end, bspnode *node);
104 int BSPReportStatus(vector *start, bspnode *node);
105
106 // Walks the BSP tree and frees up any nodes/polygons that we might be using
107 void DestroyBSPTree(bsptree *tree);
108
109 // Saves and BSP node to an open file and recurses with the nodes children
110 void SaveBSPNode(CFILE *outfile, bspnode *node);
111
112 // Loads a bsp node from an open file and recurses with its children
113 void LoadBSPNode(CFILE *infile, bspnode **node);
114
115 // Initializes some variables for the indoor bsp tree
116 void InitDefaultBSP();
117
118 // Destroy indoor bsp tree
119 void DestroyDefaultBSPTree();
120
121 // Builds a bsp tree for a single room
122 void BuildSingleBSPTree(int roomnum);
123
124 // Reports the current mine's checksum
125 int BSPGetMineChecksum();
126
127 extern bsptree MineBSP;
128 extern int BSPChecksum;
129 extern uint8_t BSP_initted;
130 extern uint8_t UseBSP;
131
132 #endif