vis.h (3909B)
1 /* 2 =========================================================================== 3 Copyright (C) 1999-2005 Id Software, Inc. 4 5 This file is part of Quake III Arena source code. 6 7 Quake III Arena source code is free software; you can redistribute it 8 and/or modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the License, 10 or (at your option) any later version. 11 12 Quake III Arena source code is distributed in the hope that it will be 13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with Foobar; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 =========================================================================== 21 */ 22 // vis.h 23 24 #include "cmdlib.h" 25 #include "mathlib.h" 26 #include "bspfile.h" 27 28 #define MAX_PORTALS 32768 29 30 #define PORTALFILE "PRT1" 31 32 #define ON_EPSILON 0.1 33 34 //#define MREDEBUG 35 36 // seperator caching helps a bit 37 #define SEPERATORCACHE 38 39 // can't have more seperators than the max number of points on a winding 40 #define MAX_SEPERATORS 64 41 42 typedef struct 43 { 44 vec3_t normal; 45 float dist; 46 } plane_t; 47 48 #define MAX_POINTS_ON_WINDING 64 49 #define MAX_POINTS_ON_FIXED_WINDING 12 50 51 typedef struct 52 { 53 int numpoints; 54 vec3_t points[MAX_POINTS_ON_FIXED_WINDING]; // variable sized 55 } winding_t; 56 57 winding_t *NewWinding (int points); 58 void FreeWinding (winding_t *w); 59 winding_t *CopyWinding (winding_t *w); 60 61 62 typedef struct passage_s 63 { 64 struct passage_s *next; 65 byte cansee[1]; //all portals that can be seen through this passage 66 } passage_t; 67 68 typedef enum {stat_none, stat_working, stat_done} vstatus_t; 69 typedef struct 70 { 71 int num; 72 qboolean hint; // true if this portal was created from a hint splitter 73 qboolean removed; 74 plane_t plane; // normal pointing into neighbor 75 int leaf; // neighbor 76 77 vec3_t origin; // for fast clip testing 78 float radius; 79 80 winding_t *winding; 81 vstatus_t status; 82 byte *portalfront; // [portals], preliminary 83 byte *portalflood; // [portals], intermediate 84 byte *portalvis; // [portals], final 85 86 int nummightsee; // bit count on portalflood for sort 87 passage_t *passages; // there are just as many passages as there 88 // are portals in the leaf this portal leads to 89 } vportal_t; 90 91 #define MAX_PORTALS_ON_LEAF 128 92 typedef struct leaf_s 93 { 94 int numportals; 95 int merged; 96 vportal_t *portals[MAX_PORTALS_ON_LEAF]; 97 } leaf_t; 98 99 100 typedef struct pstack_s 101 { 102 byte mightsee[MAX_PORTALS/8]; // bit string 103 struct pstack_s *next; 104 leaf_t *leaf; 105 vportal_t *portal; // portal exiting 106 winding_t *source; 107 winding_t *pass; 108 109 winding_t windings[3]; // source, pass, temp in any order 110 int freewindings[3]; 111 112 plane_t portalplane; 113 int depth; 114 #ifdef SEPERATORCACHE 115 plane_t seperators[2][MAX_SEPERATORS]; 116 int numseperators[2]; 117 #endif 118 } pstack_t; 119 120 typedef struct 121 { 122 vportal_t *base; 123 int c_chains; 124 pstack_t pstack_head; 125 } threaddata_t; 126 127 128 129 extern int numportals; 130 extern int portalclusters; 131 132 extern vportal_t *portals; 133 extern leaf_t *leafs; 134 135 extern int c_portaltest, c_portalpass, c_portalcheck; 136 extern int c_portalskip, c_leafskip; 137 extern int c_vistest, c_mighttest; 138 extern int c_chains; 139 140 extern byte *vismap, *vismap_p, *vismap_end; // past visfile 141 142 extern int testlevel; 143 144 extern byte *uncompressed; 145 146 extern int leafbytes, leaflongs; 147 extern int portalbytes, portallongs; 148 149 150 void LeafFlow (int leafnum); 151 152 153 void BasePortalVis(int portalnum); 154 void BetterPortalVis(int portalnum); 155 void PortalFlow(int portalnum); 156 void PassagePortalFlow(int portalnum); 157 void CreatePassages(int portalnum); 158 void PassageFlow(int portalnum); 159 160 extern vportal_t *sorted_portals[MAX_MAP_PORTALS*2]; 161 162 int CountBits (byte *bits, int numbits);