19 #ifndef ___PATHFIND_HEADER___ 20 #define ___PATHFIND_HEADER___ 27 #include <csgeom/vector3.h> 28 #include <csgeom/box.h> 29 #include <csutil/hash.h> 30 #include <iutil/objreg.h> 31 #include <csutil/array.h> 32 #include <csutil/csstring.h> 33 #include <csutil/list.h> 67 psPFMaps(iObjectRegistry* objReg);
68 psPFMap* GetRegionBySector(
const csString §orName);
69 psPFMap* GetRegionBySector(iSector* sector);
70 psPFMap* FindRegionByName(
const csString ®ionName);
73 iCollection* GetCSRegionOfSector(
const csString §orName);
75 csList<psPFMap*> regions;
78 csHash<psPFMap*, csString> regionMap;
80 iObjectRegistry* objReg;
81 csRef<iEngine> engine;
92 psAEdge(psANode* neighbour,
float cost);
110 bool Contains(psANode* node);
111 bool AddNode(psANode* node);
112 void DeleteNode(psANode* node);
114 void GrowClusterFrom(psANode* start,
int level, csList <psANode*> &unassigned);
118 int CalcFreeBorderSize(
int level);
120 csList <psANode*> parts;
121 csList <psANode*> exits;
130 enum psAState {AState_open, AState_closed, AState_unknown};
146 psANode(
const csVector3 &point);
147 psANode(
const csVector3 &point, iSector* sector);
151 void EnsureNodeIsInited(
int currARunNum);
153 void SetBestPrev(psANode* bestPrev,
float cost);
154 void CalcHeur(psANode* goal);
155 void AddEdge(psANode* neighbour,
float cost,
int level,
bool bidirectional=
true);
156 void DeleteEdges(psANode* neighbour);
158 void ConnectToPoly(psWalkPoly* poly,
bool bidirectional);
160 bool ShouldBePruned(psAMap &map);
162 void SaveToString(csString &str);
165 void LoadBasicsFromXML(iDocumentNode* node, psWalkPolyMap* wpMap, iEngine* engine);
166 void LoadEdgesFromXML(iDocumentNode* node, psAMap &map);
170 psWalkPoly* GetSomePoly();
173 void DeleteConnectionsFromNeighbours();
174 void RestoreConnectionsFromNeighbours();
177 float GetEdgeCost(psANode* neighbour);
181 csArray<csArray<psAEdge> > edges;
185 psWalkPoly* poly1, * poly2;
191 psANode* prevInOpen, * nextInOpen;
202 psAPath(psPFMaps* regions);
204 void SetMaps(psPFMaps* maps);
206 void AddNodeToFront(psANode* node);
209 void SetDest(
const csVector3 &dest);
215 void CalcLocalDest(
const csVector3 &currPoint, iSector* currSector, csVector3 &localDest);
225 csList<psANode*>::Iterator FindDirectNode(
const csVector3 &currPoint);
226 void InsertSubpath(psAPath &subpath);
227 csString GetRegionNameOfSector(
const csString §orName);
228 psANode* GetNthNode(
int n);
229 void RandomizeFirst(
const csVector3 &currPoint);
231 bool CalcLocalDestFromLocalPath(
const csVector3 &currPoint, csVector3 &localDest);
233 psANode* FindNearbyANode(
const csVector3 &pos, iSector* sector);
236 csList<psANode*> nodes;
244 psAMap(iObjectRegistry* objReg);
247 void SetObjReg(iObjectRegistry* objReg)
251 void AddNode(psANode* node);
253 void PruneSuperfluous();
257 void BuildHierarchy();
262 bool RunA(psANode* start, psANode* goal,
int level,
int maxExpands, psAPath &path);
266 bool LoadFromString(
const csString &str, psWalkPolyMap* wpMap);
267 bool LoadFromFile(
const csString &path, psWalkPolyMap* wpMap);
268 void SaveToString(csString &str);
269 bool SaveToFile(
const csString &path);
271 psANode* FindNode(
int id);
274 csList <psANode*> nodes;
275 csList <psACluster*> clusters;
276 iObjectRegistry* objReg;