2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #ifndef __AASBUILD_LOCAL_H__
30 #define __AASBUILD_LOCAL_H__
33 #include "AASFile_local.h"
38 #include "AASCluster.h"
41 //===============================================================
45 //===============================================================
47 typedef struct aasProcNode_s {
49 int children[2]; // negative numbers are (-1 - areaNumber), 0 = solid
58 idBrushBSPNode * node;
59 int numExpandedPlanes;
66 idLedge( const idVec3 &v1, const idVec3 &v2, const idVec3 &gravityDir, idBrushBSPNode *n );
67 void AddPoint( const idVec3 &v );
68 void CreateBevels( const idVec3 &gravityDir );
69 void Expand( const idBounds &bounds, float maxStepHeight );
70 idWinding * ChopWinding( const idWinding *winding ) const;
71 bool PointBetweenBounds( const idVec3 &v ) const;
80 bool Build( const idStr &fileName, const idAASSettings *settings );
81 bool BuildReachability( const idStr &fileName, const idAASSettings *settings );
82 void Shutdown( void );
85 const idAASSettings * aasSettings;
86 idAASFileLocal * file;
87 aasProcNode_t * procNodes;
89 int numGravitationalSubdivisions;
90 int numMergedLeafNodes;
91 int numLedgeSubdivisions;
92 idList<idLedge> ledgeList;
93 idBrushMap * ledgeMap;
95 private: // map loading
96 void ParseProcNodes( idLexer *src );
97 bool LoadProcBSP( const char *name, ID_TIME_T minFileTime );
98 void DeleteProcBSP( void );
99 bool ChoppedAwayByProcBSP( int nodeNum, idFixedWinding *w, const idVec3 &normal, const idVec3 &origin, const float radius );
100 void ClipBrushSidesWithProcBSP( idBrushList &brushList );
101 int ContentsForAAS( int contents );
102 idBrushList AddBrushesForMapBrush( const idMapBrush *mapBrush, const idVec3 &origin, const idMat3 &axis, int entityNum, int primitiveNum, idBrushList brushList );
103 idBrushList AddBrushesForMapPatch( const idMapPatch *mapPatch, const idVec3 &origin, const idMat3 &axis, int entityNum, int primitiveNum, idBrushList brushList );
104 idBrushList AddBrushesForMapEntity( const idMapEntity *mapEnt, int entityNum, idBrushList brushList );
105 idBrushList AddBrushesForMapFile( const idMapFile * mapFile, idBrushList brushList );
106 bool CheckForEntities( const idMapFile *mapFile, idStrList &entityClassNames ) const;
107 void ChangeMultipleBoundingBoxContents_r( idBrushBSPNode *node, int mask );
109 private: // gravitational subdivision
110 void SetPortalFlags_r( idBrushBSPNode *node );
111 bool PortalIsGap( idBrushBSPPortal *portal, int side );
112 void GravSubdivLeafNode( idBrushBSPNode *node );
113 void GravSubdiv_r( idBrushBSPNode *node );
114 void GravitationalSubdivision( idBrushBSP &bsp );
116 private: // ledge subdivision
117 void LedgeSubdivFlood_r( idBrushBSPNode *node, const idLedge *ledge );
118 void LedgeSubdivLeafNodes_r( idBrushBSPNode *node, const idLedge *ledge );
119 void LedgeSubdiv( idBrushBSPNode *root );
120 bool IsLedgeSide_r( idBrushBSPNode *node, idFixedWinding *w, const idPlane &plane, const idVec3 &normal, const idVec3 &origin, const float radius );
121 void AddLedge( const idVec3 &v1, const idVec3 &v2, idBrushBSPNode *node );
122 void FindLeafNodeLedges( idBrushBSPNode *root, idBrushBSPNode *node );
123 void FindLedges_r( idBrushBSPNode *root, idBrushBSPNode *node );
124 void LedgeSubdivision( idBrushBSP &bsp );
125 void WriteLedgeMap( const idStr &fileName, const idStr &ext );
128 bool AllGapsLeadToOtherNode( idBrushBSPNode *nodeWithGaps, idBrushBSPNode *otherNode );
129 bool MergeWithAdjacentLeafNodes( idBrushBSP &bsp, idBrushBSPNode *node );
130 void MergeLeafNodes_r( idBrushBSP &bsp, idBrushBSPNode *node );
131 void MergeLeafNodes( idBrushBSP &bsp );
133 private: // storing file
134 void SetupHash( void );
135 void ShutdownHash( void );
136 void ClearHash( const idBounds &bounds );
137 int HashVec( const idVec3 &vec );
138 bool GetVertex( const idVec3 &v, int *vertexNum );
139 bool GetEdge( const idVec3 &v1, const idVec3 &v2, int *edgeNum, int v1num );
140 bool GetFaceForPortal( idBrushBSPPortal *portal, int side, int *faceNum );
141 bool GetAreaForLeafNode( idBrushBSPNode *node, int *areaNum );
142 int StoreTree_r( idBrushBSPNode *node );
143 void GetSizeEstimate_r( idBrushBSPNode *parent, idBrushBSPNode *node, struct sizeEstimate_s &size );
144 void SetSizeEstimate( const idBrushBSP &bsp, idAASFileLocal *file );
145 bool StoreFile( const idBrushBSP &bsp );
149 #endif /* !__AASBUILD_LOCAL_H__ */