doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AAS_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 __AAS_LOCAL_H__
30 #define __AAS_LOCAL_H__
31 
32 #include "AAS.h"
33 #include "../Pvs.h"
34 
35 
37  friend class idAASLocal;
38 
39 public:
40  idRoutingCache( int size );
41  ~idRoutingCache( void );
42 
43  int Size( void ) const;
44 
45 private:
46  int type; // portal or area cache
47  int size; // size of cache
48  int cluster; // cluster of the cache
49  int areaNum; // area of the cache
50  int travelFlags; // combinations of the travel flags
51  idRoutingCache * next; // next in list
52  idRoutingCache * prev; // previous in list
53  idRoutingCache * time_next; // next in time based list
54  idRoutingCache * time_prev; // previous in time based list
55  unsigned short startTravelTime; // travel time to start with
56  unsigned char * reachabilities; // reachabilities used for routing
57  unsigned short * travelTimes; // travel time for every area
58 };
59 
60 
62  friend class idAASLocal;
63 
64 private:
65  int cluster; // cluster number of this update
66  int areaNum; // area number of this update
67  unsigned short tmpTravelTime; // temporary travel time
68  unsigned short * areaTravelTimes; // travel times within the area
69  idVec3 start; // start point into area
70  idRoutingUpdate * next; // next in list
71  idRoutingUpdate * prev; // prev in list
72  bool isInList; // true if the update is in the list
73 };
74 
75 
77  friend class idAASLocal;
78  idRoutingObstacle( void ) { }
79 
80 private:
81  idBounds bounds; // obstacle bounds
82  idList<int> areas; // areas the bounds are in
83 };
84 
85 
86 class idAASLocal : public idAAS {
87 public:
88  idAASLocal( void );
89  virtual ~idAASLocal( void );
90  virtual bool Init( const idStr &mapName, unsigned int mapFileCRC );
91  virtual void Shutdown( void );
92  virtual void Stats( void ) const;
93  virtual void Test( const idVec3 &origin );
94  virtual const idAASSettings *GetSettings( void ) const;
95  virtual int PointAreaNum( const idVec3 &origin ) const;
96  virtual int PointReachableAreaNum( const idVec3 &origin, const idBounds &searchBounds, const int areaFlags ) const;
97  virtual int BoundsReachableAreaNum( const idBounds &bounds, const int areaFlags ) const;
98  virtual void PushPointIntoAreaNum( int areaNum, idVec3 &origin ) const;
99  virtual idVec3 AreaCenter( int areaNum ) const;
100  virtual int AreaFlags( int areaNum ) const;
101  virtual int AreaTravelFlags( int areaNum ) const;
102  virtual bool Trace( aasTrace_t &trace, const idVec3 &start, const idVec3 &end ) const;
103  virtual const idPlane & GetPlane( int planeNum ) const;
104  virtual int GetWallEdges( int areaNum, const idBounds &bounds, int travelFlags, int *edges, int maxEdges ) const;
105  virtual void SortWallEdges( int *edges, int numEdges ) const;
106  virtual void GetEdgeVertexNumbers( int edgeNum, int verts[2] ) const;
107  virtual void GetEdge( int edgeNum, idVec3 &start, idVec3 &end ) const;
108  virtual bool SetAreaState( const idBounds &bounds, const int areaContents, bool disabled );
109  virtual aasHandle_t AddObstacle( const idBounds &bounds );
110  virtual void RemoveObstacle( const aasHandle_t handle );
111  virtual void RemoveAllObstacles( void );
112  virtual int TravelTimeToGoalArea( int areaNum, const idVec3 &origin, int goalAreaNum, int travelFlags ) const;
113  virtual bool RouteToGoalArea( int areaNum, const idVec3 origin, int goalAreaNum, int travelFlags, int &travelTime, idReachability **reach ) const;
114  virtual bool WalkPathToGoal( aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags ) const;
115  virtual bool WalkPathValid( int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum ) const;
116  virtual bool FlyPathToGoal( aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags ) const;
117  virtual bool FlyPathValid( int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum ) const;
118  virtual void ShowWalkPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const;
119  virtual void ShowFlyPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const;
120  virtual bool FindNearestGoal( aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, aasObstacle_t *obstacles, int numObstacles, idAASCallback &callback ) const;
121 
122 private:
125 
126 private: // routing data
127  idRoutingCache *** areaCacheIndex; // for each area in each cluster the travel times to all other areas in the cluster
128  int areaCacheIndexSize; // number of area cache entries
129  idRoutingCache ** portalCacheIndex; // for each area in the world the travel times from each portal
130  int portalCacheIndexSize; // number of portal cache entries
131  idRoutingUpdate * areaUpdate; // memory used to update the area routing cache
132  idRoutingUpdate * portalUpdate; // memory used to update the portal routing cache
133  unsigned short * goalAreaTravelTimes; // travel times to goal areas
134  unsigned short * areaTravelTimes; // travel times through the areas
135  int numAreaTravelTimes; // number of area travel times
136  mutable idRoutingCache * cacheListStart; // start of list with cache sorted from oldest to newest
137  mutable idRoutingCache * cacheListEnd; // end of list with cache sorted from oldest to newest
138  mutable int totalCacheMemory; // total cache memory used
140 
141 private: // routing
142  bool SetupRouting( void );
143  void ShutdownRouting( void );
144  unsigned short AreaTravelTime( int areaNum, const idVec3 &start, const idVec3 &end ) const;
145  void CalculateAreaTravelTimes( void );
146  void DeleteAreaTravelTimes( void );
147  void SetupRoutingCache( void );
148  void DeleteClusterCache( int clusterNum );
149  void DeletePortalCache( void );
150  void ShutdownRoutingCache( void );
151  void RoutingStats( void ) const;
152  void LinkCache( idRoutingCache *cache ) const;
153  void UnlinkCache( idRoutingCache *cache ) const;
154  void DeleteOldestCache( void ) const;
155  idReachability * GetAreaReachability( int areaNum, int reachabilityNum ) const;
156  int ClusterAreaNum( int clusterNum, int areaNum ) const;
157  void UpdateAreaRoutingCache( idRoutingCache *areaCache ) const;
158  idRoutingCache * GetAreaRoutingCache( int clusterNum, int areaNum, int travelFlags ) const;
159  void UpdatePortalRoutingCache( idRoutingCache *portalCache ) const;
160  idRoutingCache * GetPortalRoutingCache( int clusterNum, int areaNum, int travelFlags ) const;
161  void RemoveRoutingCacheUsingArea( int areaNum );
162  void DisableArea( int areaNum );
163  void EnableArea( int areaNum );
164  bool SetAreaState_r( int nodeNum, const idBounds &bounds, const int areaContents, bool disabled );
165  void GetBoundsAreas_r( int nodeNum, const idBounds &bounds, idList<int> &areas ) const;
166  void SetObstacleState( const idRoutingObstacle *obstacle, bool enable );
167 
168 private: // pathing
169  bool EdgeSplitPoint( idVec3 &split, int edgeNum, const idPlane &plane ) const;
170  bool FloorEdgeSplitPoint( idVec3 &split, int areaNum, const idPlane &splitPlane, const idPlane &frontPlane, bool closest ) const;
171  idVec3 SubSampleWalkPath( int areaNum, const idVec3 &origin, const idVec3 &start, const idVec3 &end, int travelFlags, int &endAreaNum ) const;
172  idVec3 SubSampleFlyPath( int areaNum, const idVec3 &origin, const idVec3 &start, const idVec3 &end, int travelFlags, int &endAreaNum ) const;
173 
174 private: // debug
175  const idBounds & DefaultSearchBounds( void ) const;
176  void DrawCone( const idVec3 &origin, const idVec3 &dir, float radius, const idVec4 &color ) const;
177  void DrawArea( int areaNum ) const;
178  void DrawFace( int faceNum, bool side ) const;
179  void DrawEdge( int edgeNum, bool arrow ) const;
180  void DrawReachability( const idReachability *reach ) const;
181  void ShowArea( const idVec3 &origin ) const;
182  void ShowWallEdges( const idVec3 &origin ) const;
183  void ShowHideArea( const idVec3 &origin, int targerAreaNum ) const;
184  bool PullPlayer( const idVec3 &origin, int toAreaNum ) const;
185  void RandomPullPlayer( const idVec3 &origin ) const;
186  void ShowPushIntoArea( const idVec3 &origin ) const;
187 };
188 
189 #endif /* !__AAS_LOCAL_H__ */
idRoutingObstacle(void)
Definition: AAS_local.h:78
idRoutingCache * GetPortalRoutingCache(int clusterNum, int areaNum, int travelFlags) const
byte color[4]
Definition: MegaTexture.cpp:54
void ShutdownRoutingCache(void)
void DrawArea(int areaNum) const
Definition: AAS_debug.cpp:150
virtual void ShowFlyPath(const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin) const
Definition: AAS_debug.cpp:290
virtual const idPlane & GetPlane(int planeNum) const
Definition: AAS.cpp:238
unsigned short * goalAreaTravelTimes
Definition: AAS_local.h:133
virtual void Test(const idVec3 &origin)
Definition: AAS_debug.cpp:477
idVec3 SubSampleFlyPath(int areaNum, const idVec3 &origin, const idVec3 &start, const idVec3 &end, int travelFlags, int &endAreaNum) const
virtual void Shutdown(void)
Definition: AAS.cpp:97
bool SetAreaState_r(int nodeNum, const idBounds &bounds, const int areaContents, bool disabled)
void DeletePortalCache(void)
idList< idRoutingObstacle * > obstacleList
Definition: AAS_local.h:139
void DrawFace(int faceNum, bool side) const
Definition: AAS_debug.cpp:116
virtual void Stats(void) const
Definition: AAS.cpp:111
idVec3 SubSampleWalkPath(int areaNum, const idVec3 &origin, const idVec3 &start, const idVec3 &end, int travelFlags, int &endAreaNum) const
virtual bool FlyPathValid(int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum) const
void RoutingStats(void) const
unsigned char * reachabilities
Definition: AAS_local.h:56
void ShowArea(const idVec3 &origin) const
Definition: AAS_debug.cpp:186
idList< int > areas
Definition: AAS_local.h:82
virtual void PushPointIntoAreaNum(int areaNum, idVec3 &origin) const
Definition: AAS.cpp:175
idRoutingCache * next
Definition: AAS_local.h:51
idRoutingCache * cacheListEnd
Definition: AAS_local.h:137
idReachability * GetAreaReachability(int areaNum, int reachabilityNum) const
virtual void GetEdge(int edgeNum, idVec3 &start, idVec3 &end) const
Definition: AAS.cpp:266
Definition: AAS.h:56
prefInfo callback
int numAreaTravelTimes
Definition: AAS_local.h:135
idRoutingUpdate * prev
Definition: AAS_local.h:71
Definition: Vector.h:316
idRoutingCache * cacheListStart
Definition: AAS_local.h:136
void SetObstacleState(const idRoutingObstacle *obstacle, bool enable)
virtual int AreaFlags(int areaNum) const
Definition: AAS.cpp:199
idRoutingUpdate * portalUpdate
Definition: AAS_local.h:132
idAASLocal(void)
Definition: AAS.cpp:56
void GetBoundsAreas_r(int nodeNum, const idBounds &bounds, idList< int > &areas) const
idRoutingUpdate * next
Definition: AAS_local.h:70
idRoutingCache(int size)
Definition: AAS_routing.cpp:47
void ShutdownRouting(void)
idRoutingUpdate * areaUpdate
Definition: AAS_local.h:131
~idRoutingCache(void)
Definition: AAS_routing.cpp:67
int areaCacheIndexSize
Definition: AAS_local.h:128
int portalCacheIndexSize
Definition: AAS_local.h:130
idRoutingCache * time_prev
Definition: AAS_local.h:54
idAASFile * file
Definition: AAS_local.h:123
virtual void GetEdgeVertexNumbers(int edgeNum, int verts[2]) const
Definition: AAS.cpp:251
bool EdgeSplitPoint(idVec3 &split, int edgeNum, const idPlane &plane) const
Definition: AAS_pathing.cpp:54
unsigned short startTravelTime
Definition: AAS_local.h:55
Definition: AAS.h:47
void SetupRoutingCache(void)
void RandomPullPlayer(const idVec3 &origin) const
Definition: AAS_debug.cpp:439
void CalculateAreaTravelTimes(void)
Definition: Vector.h:808
virtual bool WalkPathValid(int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum) const
virtual void RemoveAllObstacles(void)
virtual aasHandle_t AddObstacle(const idBounds &bounds)
GLuint GLuint end
Definition: glext.h:2845
void ShowPushIntoArea(const idVec3 &origin) const
Definition: AAS_debug.cpp:462
unsigned short * travelTimes
Definition: AAS_local.h:57
virtual bool RouteToGoalArea(int areaNum, const idVec3 origin, int goalAreaNum, int travelFlags, int &travelTime, idReachability **reach) const
virtual ~idAASLocal(void)
Definition: AAS.cpp:65
unsigned short * areaTravelTimes
Definition: AAS_local.h:134
unsigned short tmpTravelTime
Definition: AAS_local.h:67
int totalCacheMemory
Definition: AAS_local.h:138
void ShowHideArea(const idVec3 &origin, int targerAreaNum) const
Definition: AAS_debug.cpp:360
virtual void RemoveObstacle(const aasHandle_t handle)
Definition: Plane.h:71
virtual bool FindNearestGoal(aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, aasObstacle_t *obstacles, int numObstacles, idAASCallback &callback) const
bool FloorEdgeSplitPoint(idVec3 &split, int areaNum, const idPlane &splitPlane, const idPlane &frontPlane, bool closest) const
Definition: AAS_pathing.cpp:81
void UpdatePortalRoutingCache(idRoutingCache *portalCache) const
const char * path
Definition: sws.c:117
int aasHandle_t
Definition: AAS.h:73
idVec3 start
Definition: AAS_local.h:69
bool SetupRouting(void)
virtual bool FlyPathToGoal(aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags) const
unsigned short * areaTravelTimes
Definition: AAS_local.h:68
virtual int PointReachableAreaNum(const idVec3 &origin, const idBounds &searchBounds, const int areaFlags) const
Definition: AAS.cpp:149
const idBounds & DefaultSearchBounds(void) const
Definition: AAS_debug.cpp:177
virtual void SortWallEdges(int *edges, int numEdges) const
idStr name
Definition: AAS_local.h:124
bool PullPlayer(const idVec3 &origin, int toAreaNum) const
Definition: AAS_debug.cpp:388
virtual bool WalkPathToGoal(aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags) const
void DrawEdge(int edgeNum, bool arrow) const
Definition: AAS_debug.cpp:90
idBounds bounds
Definition: AAS_local.h:81
int Size(void) const
Definition: AAS_routing.cpp:77
virtual const idAASSettings * GetSettings(void) const
Definition: AAS.cpp:125
idRoutingCache * time_next
Definition: AAS_local.h:53
void RemoveRoutingCacheUsingArea(int areaNum)
GLsizeiptr size
Definition: glext.h:3112
void UnlinkCache(idRoutingCache *cache) const
idRoutingCache *** areaCacheIndex
Definition: AAS_local.h:127
void DrawReachability(const idReachability *reach) const
Definition: AAS_debug.cpp:67
Definition: Str.h:116
void DrawCone(const idVec3 &origin, const idVec3 &dir, float radius, const idVec4 &color) const
Definition: AAS_debug.cpp:41
void UpdateAreaRoutingCache(idRoutingCache *areaCache) const
unsigned short AreaTravelTime(int areaNum, const idVec3 &start, const idVec3 &end) const
Definition: AAS_routing.cpp:86
void EnableArea(int areaNum)
virtual int BoundsReachableAreaNum(const idBounds &bounds, const int areaFlags) const
Definition: AAS.cpp:162
void DeleteClusterCache(int clusterNum)
virtual bool Init(const idStr &mapName, unsigned int mapFileCRC)
Definition: AAS.cpp:74
idRoutingCache * prev
Definition: AAS_local.h:52
virtual void ShowWalkPath(const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin) const
Definition: AAS_debug.cpp:244
void DeleteOldestCache(void) const
virtual int AreaTravelFlags(int areaNum) const
Definition: AAS.cpp:211
virtual int GetWallEdges(int areaNum, const idBounds &bounds, int travelFlags, int *edges, int maxEdges) const
void LinkCache(idRoutingCache *cache) const
void DeleteAreaTravelTimes(void)
void DisableArea(int areaNum)
virtual bool SetAreaState(const idBounds &bounds, const int areaContents, bool disabled)
virtual int PointAreaNum(const idVec3 &origin) const
Definition: AAS.cpp:137
idRoutingCache * GetAreaRoutingCache(int clusterNum, int areaNum, int travelFlags) const
void ShowWallEdges(const idVec3 &origin) const
Definition: AAS_debug.cpp:336
GLuint start
Definition: glext.h:2845
int ClusterAreaNum(int clusterNum, int areaNum) const
virtual bool Trace(aasTrace_t &trace, const idVec3 &start, const idVec3 &end) const
Definition: AAS.cpp:223
Definition: AAS.h:75
virtual idVec3 AreaCenter(int areaNum) const
Definition: AAS.cpp:187
idRoutingCache ** portalCacheIndex
Definition: AAS_local.h:129
virtual int TravelTimeToGoalArea(int areaNum, const idVec3 &origin, int goalAreaNum, int travelFlags) const