]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/tools/compilers/aas/AASBuild_local.h
hello world
[icculus/iodoom3.git] / neo / tools / compilers / aas / AASBuild_local.h
1 /*
2 ===========================================================================
3
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. 
6
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).  
8
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.
13
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.
18
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/>.
21
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.
23
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.
25
26 ===========================================================================
27 */
28
29 #ifndef __AASBUILD_LOCAL_H__
30 #define __AASBUILD_LOCAL_H__
31
32 #include "AASFile.h"
33 #include "AASFile_local.h"
34
35 #include "Brush.h"
36 #include "BrushBSP.h"
37 #include "AASReach.h"
38 #include "AASCluster.h"
39
40
41 //===============================================================
42 //
43 //      idAASBuild
44 //
45 //===============================================================
46
47 typedef struct aasProcNode_s {
48         idPlane plane;
49         int children[2];                // negative numbers are (-1 - areaNumber), 0 = solid
50 } aasProcNode_t;
51
52
53 class idLedge {
54
55 public:
56         idVec3                                  start;
57         idVec3                                  end;
58         idBrushBSPNode *                node;
59         int                                             numExpandedPlanes;
60         int                                             numSplitPlanes;
61         int                                             numPlanes;
62         idPlane                                 planes[8];
63
64 public:
65                                                         idLedge( void );
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;
72 };
73
74
75 class idAASBuild {
76
77 public:
78                                                         idAASBuild( void );
79                                                         ~idAASBuild( void );
80         bool                                    Build( const idStr &fileName, const idAASSettings *settings );
81         bool                                    BuildReachability( const idStr &fileName, const idAASSettings *settings );
82         void                                    Shutdown( void );
83
84 private:
85         const idAASSettings *   aasSettings;
86         idAASFileLocal *                file;
87         aasProcNode_t *                 procNodes;
88         int                                             numProcNodes;
89         int                                             numGravitationalSubdivisions;
90         int                                             numMergedLeafNodes;
91         int                                             numLedgeSubdivisions;
92         idList<idLedge>                 ledgeList;
93         idBrushMap *                    ledgeMap;
94
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 );
108
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 );
115
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 );
126
127 private:        // merging
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 );
132
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 );
146
147 };
148
149 #endif /* !__AASBUILD_LOCAL_H__ */