| 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_Hcxx . . $ `Descent3/bsp.h:42:9`! |
| 43 | |
| 44 | #include "list.h"cxx . . $ `<file>/Descent3/list.h`/ |
| 45 | #include "vecmat.h"cxx . . $ `<file>/lib/vecmat.h`/ |
| 46 | #include "cfile.h"cxx . . $ `<file>/cfile/cfile.h`/ |
| 47 | |
| 48 | #define BSP_IN_FRONTcxx . . $ `Descent3/bsp.h:48:9`! 1 |
| 49 | #define BSP_BEHINDcxx . . $ `Descent3/bsp.h:49:9`! 2 |
| 50 | #define BSP_ON_PLANEcxx . . $ `Descent3/bsp.h:50:9`! 3 |
| 51 | #define BSP_SPANNINGcxx . . $ `Descent3/bsp.h:51:9`! 4 |
| 52 | #define BSP_COINCIDENTcxx . . $ `Descent3/bsp.h:52:9`! 5 |
| 53 | |
| 54 | #define BSP_EPSILONcxx . . $ `Descent3/bsp.h:54:9`! .00005f |
| 55 | |
| 56 | #define BSP_NODEcxx . . $ `Descent3/bsp.h:56:9`! 0 |
| 57 | #define BSP_EMPTY_LEAFcxx . . $ `Descent3/bsp.h:57:9`! 1 |
| 58 | #define BSP_SOLID_LEAFcxx . . $ `Descent3/bsp.h:58:9`! 2 |
| 59 | |
| 60 | struct bspplanecxx . . $ bspplane# { |
| 61 | float acxx . . $ bspplane#a., bcxx . . $ bspplane#b., ccxx . . $ bspplane#c., dcxx . . $ bspplane#d.; |
| 62 | uint8_tcxx . . $ uint8_t# usedcxx . . $ bspplane#used.; |
| 63 | }; |
| 64 | |
| 65 | struct bsppolygoncxx . . $ bsppolygon# { |
| 66 | vectorcxx . . $ vector# *vertscxx . . $ bsppolygon#verts.; |
| 67 | int nvcxx . . $ bsppolygon#nv.; |
| 68 | bspplanecxx . . $ bspplane# planecxx . . $ bsppolygon#plane.; |
| 69 | |
| 70 | int16_t roomnumcxx . . $ bsppolygon#roomnum.; |
| 71 | int16_t facenumcxx . . $ bsppolygon#facenum.; |
| 72 | int8_t subnumcxx . . $ bsppolygon#subnum.; |
| 73 | |
| 74 | int colorcxx . . $ bsppolygon#color.; |
| 75 | |
| 76 | }; |
| 77 | |
| 78 | struct bspnodecxx . . $ bspnode# { |
| 79 | uint8_tcxx . . $ uint8_t# typecxx . . $ bspnode#type.; |
| 80 | bspplanecxx . . $ bspplane# planecxx . . $ bspnode#plane.; |
| 81 | uint16_tcxx . . $ uint16_t# node_facenumcxx . . $ bspnode#node_facenum.; |
| 82 | uint16_tcxx . . $ uint16_t# node_roomnumcxx . . $ bspnode#node_roomnum.; |
| 83 | int8_t node_subnumcxx . . $ bspnode#node_subnum.; |
| 84 | |
| 85 | bspnodecxx . . $ bspnode# *frontcxx . . $ bspnode#front.; |
| 86 | bspnodecxx . . $ bspnode# *backcxx . . $ bspnode#back.; |
| 87 | |
| 88 | listnodecxx . . $ listnode# *polylistcxx . . $ bspnode#polylist.; |
| 89 | int num_polyscxx . . $ bspnode#num_polys.; |
| 90 | }; |
| 91 | |
| 92 | struct bsptreecxx . . $ bsptree# { |
| 93 | listnodecxx . . $ listnode# *vertlistcxx . . $ bsptree#vertlist.; |
| 94 | listnodecxx . . $ listnode# *polylistcxx . . $ bsptree#polylist.; |
| 95 | bspnodecxx . . $ bspnode# *rootcxx . . $ bsptree#root.; |
| 96 | }; |
| 97 | |
| 98 | // Builds a bsp tree for the indoor rooms |
| 99 | void BuildBSPTreecxx . . $ BuildBSPTree(49f6e7a06ebc5aa8).(); |
| 100 | |
| 101 | // Runs a ray through the bsp tree |
| 102 | // Returns true if a ray is occludes |
| 103 | int BSPRayOccludedcxx . . $ BSPRayOccluded(96b8ef6b7178d0f9).(vectorcxx . . $ vector# *start, vectorcxx . . $ vector# *end, bspnodecxx . . $ bspnode# *node); |
| 104 | int BSPReportStatuscxx . . $ BSPReportStatus(1bca2165ccd1151b).(vectorcxx . . $ vector# *start, bspnodecxx . . $ bspnode# *node); |
| 105 | |
| 106 | // Walks the BSP tree and frees up any nodes/polygons that we might be using |
| 107 | void DestroyBSPTreecxx . . $ DestroyBSPTree(450b197686544216).(bsptreecxx . . $ bsptree# *tree); |
| 108 | |
| 109 | // Saves and BSP node to an open file and recurses with the nodes children |
| 110 | void SaveBSPNodecxx . . $ SaveBSPNode(4506aeb41eee2e7).(CFILEcxx . . $ CFILE# *outfile, bspnodecxx . . $ bspnode# *node); |
| 111 | |
| 112 | // Loads a bsp node from an open file and recurses with its children |
| 113 | void LoadBSPNodecxx . . $ LoadBSPNode(f7470add2ab7fa30).(CFILEcxx . . $ CFILE# *infile, bspnodecxx . . $ bspnode# **node); |
| 114 | |
| 115 | // Initializes some variables for the indoor bsp tree |
| 116 | void InitDefaultBSPcxx . . $ InitDefaultBSP(49f6e7a06ebc5aa8).(); |
| 117 | |
| 118 | // Destroy indoor bsp tree |
| 119 | void DestroyDefaultBSPTreecxx . . $ DestroyDefaultBSPTree(49f6e7a06ebc5aa8).(); |
| 120 | |
| 121 | // Builds a bsp tree for a single room |
| 122 | void BuildSingleBSPTreecxx . . $ BuildSingleBSPTree(d4f767463ce0a6b3).(int roomnum); |
| 123 | |
| 124 | // Reports the current mine's checksum |
| 125 | int BSPGetMineChecksumcxx . . $ BSPGetMineChecksum(b126dc7c1de90089).(); |
| 126 | |
| 127 | extern bsptreecxx . . $ bsptree# MineBSPcxx . . $ MineBSP.; |
| 128 | extern int BSPChecksumcxx . . $ BSPChecksum.; |
| 129 | extern uint8_tcxx . . $ uint8_t# BSP_inittedcxx . . $ BSP_initted.; |
| 130 | extern uint8_tcxx . . $ uint8_t# UseBSPcxx . . $ UseBSP.; |
| 131 | |
| 132 | #endif |