doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AASBuild_local.h
Go to the documentation of this file.
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 {
49  int children[2]; // negative numbers are (-1 - areaNumber), 0 = solid
51 
52 
53 class idLedge {
54 
55 public:
61  int numPlanes;
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:
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;
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 );
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 );
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__ */
void SetSizeEstimate(const idBrushBSP &bsp, idAASFileLocal *file)
idPlane planes[8]
void CreateBevels(const idVec3 &gravityDir)
idVec3 start
bool BuildReachability(const idStr &fileName, const idAASSettings *settings)
Definition: AASBuild.cpp:794
bool StoreFile(const idBrushBSP &bsp)
void GravSubdiv_r(idBrushBSPNode *node)
void MergeLeafNodes(idBrushBSP &bsp)
int numMergedLeafNodes
idBrushList AddBrushesForMapFile(const idMapFile *mapFile, idBrushList brushList)
Definition: AASBuild.cpp:546
idLedge(void)
idWinding * ChopWinding(const idWinding *winding) const
void AddLedge(const idVec3 &v1, const idVec3 &v2, idBrushBSPNode *node)
void GetSizeEstimate_r(idBrushBSPNode *parent, idBrushBSPNode *node, struct sizeEstimate_s &size)
GLenum GLint GLuint mask
Definition: glext.h:5864
const GLdouble * v
Definition: glext.h:2936
idBrushList AddBrushesForMapPatch(const idMapPatch *mapPatch, const idVec3 &origin, const idMat3 &axis, int entityNum, int primitiveNum, idBrushList brushList)
Definition: AASBuild.cpp:374
bool PortalIsGap(idBrushBSPPortal *portal, int side)
GLenum GLsizei n
Definition: glext.h:3705
bool LoadProcBSP(const char *name, ID_TIME_T minFileTime)
Definition: AASBuild.cpp:122
bool GetEdge(const idVec3 &v1, const idVec3 &v2, int *edgeNum, int v1num)
int ContentsForAAS(int contents)
Definition: AASBuild.cpp:302
void GravSubdivLeafNode(idBrushBSPNode *node)
Definition: Vector.h:316
int numPlanes
void LedgeSubdivision(idBrushBSP &bsp)
GLuint src
Definition: glext.h:5390
void FindLeafNodeLedges(idBrushBSPNode *root, idBrushBSPNode *node)
idBrushList AddBrushesForMapEntity(const idMapEntity *mapEnt, int entityNum, idBrushList brushList)
Definition: AASBuild.cpp:503
void LedgeSubdiv(idBrushBSPNode *root)
void WriteLedgeMap(const idStr &fileName, const idStr &ext)
bool GetFaceForPortal(idBrushBSPPortal *portal, int side, int *faceNum)
int numSplitPlanes
idList< idLedge > ledgeList
bool Build(const idStr &fileName, const idAASSettings *settings)
Definition: AASBuild.cpp:639
int numGravitationalSubdivisions
GLfloat GLfloat GLfloat v2
Definition: glext.h:3608
Definition: Lexer.h:137
idAASFileLocal * file
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:3454
void AddPoint(const idVec3 &v)
bool GetAreaForLeafNode(idBrushBSPNode *node, int *areaNum)
bool CheckForEntities(const idMapFile *mapFile, idStrList &entityClassNames) const
Definition: AASBuild.cpp:571
void ChangeMultipleBoundingBoxContents_r(idBrushBSPNode *node, int mask)
Definition: AASBuild.cpp:624
void SetupHash(void)
int StoreTree_r(idBrushBSPNode *node)
void ShutdownHash(void)
Definition: Plane.h:71
void ParseProcNodes(idLexer *src)
Definition: AASBuild.cpp:93
int numLedgeSubdivisions
const idAASSettings * aasSettings
void Shutdown(void)
Definition: AASBuild.cpp:71
void LedgeSubdivFlood_r(idBrushBSPNode *node, const idLedge *ledge)
void MergeLeafNodes_r(idBrushBSP &bsp, idBrushBSPNode *node)
aasProcNode_t * procNodes
bool ChoppedAwayByProcBSP(int nodeNum, idFixedWinding *w, const idVec3 &normal, const idVec3 &origin, const float radius)
Definition: AASBuild.cpp:201
GLfloat GLfloat v1
Definition: glext.h:3607
int HashVec(const idVec3 &vec)
~idAASBuild(void)
Definition: AASBuild.cpp:62
bool MergeWithAdjacentLeafNodes(idBrushBSP &bsp, idBrushBSPNode *node)
void GravitationalSubdivision(idBrushBSP &bsp)
Definition: Matrix.h:333
idBrushList AddBrushesForMapBrush(const idMapBrush *mapBrush, const idVec3 &origin, const idMat3 &axis, int entityNum, int primitiveNum, idBrushList brushList)
Definition: AASBuild.cpp:326
idVec3 end
idBrushBSPNode * node
const GLcharARB * name
Definition: glext.h:3629
GLsizeiptr size
Definition: glext.h:3112
int numExpandedPlanes
void ClipBrushSidesWithProcBSP(idBrushList &brushList)
Definition: AASBuild.cpp:259
bool GetVertex(const idVec3 &v, int *vertexNum)
idBrushMap * ledgeMap
Definition: Str.h:116
bool PointBetweenBounds(const idVec3 &v) const
bool AllGapsLeadToOtherNode(idBrushBSPNode *nodeWithGaps, idBrushBSPNode *otherNode)
void SetPortalFlags_r(idBrushBSPNode *node)
void FindLedges_r(idBrushBSPNode *root, idBrushBSPNode *node)
void LedgeSubdivLeafNodes_r(idBrushBSPNode *node, const idLedge *ledge)
void Expand(const idBounds &bounds, float maxStepHeight)
struct aasProcNode_s aasProcNode_t
bool IsLedgeSide_r(idBrushBSPNode *node, idFixedWinding *w, const idPlane &plane, const idVec3 &normal, const idVec3 &origin, const float radius)
void ClearHash(const idBounds &bounds)
idAASBuild(void)
Definition: AASBuild.cpp:47
void DeleteProcBSP(void)
Definition: AASBuild.cpp:188