PathFinder.h
Go to the documentation of this file.00001 00020 #ifndef __PathFinder_H__ 00021 #define __PathFinder_H__ 00022 00023 // Includes 00024 #include "HashTable.h" 00025 #include "HashTableKey_Pointer.h" 00026 #include "MemoryPool.h" 00027 #include "PathFinderAgent.h" 00028 #include "PathFinderCell.h" 00029 #include "PriorityQueue.h" 00030 #include "Array.h" 00031 00032 // Forward declares 00033 00034 00035 // PathFinder 00036 class PathFinder 00037 { 00038 public: 00039 PathFinder(); 00040 00046 bool FindPath( 00047 const PathFinderAgent* agent, 00048 const PathFinderCell* start, 00049 const PathFinderCell* end, 00050 Array<const PathFinderCell*>& path, 00051 int iterationSafetyLimit=80000 00052 ); 00053 00054 00055 private: 00059 struct PathFinderNode 00060 { 00061 float costFromStart; 00062 float estimatedCostToGoal; 00063 float nodeScore; 00064 PathFinderNode* parent; 00065 const PathFinderCell* cell; 00066 bool closed; 00067 }; 00068 00069 private: 00074 void ClearLists(); 00075 00083 PathFinderNode* GetNodeFromCell(const PathFinderCell* cell); 00084 00090 void BuildPath(PathFinderNode* node,Array<const PathFinderCell*>& path); 00091 00092 00093 static bool PriorityCompareFunction(PathFinderNode* const &a, PathFinderNode* const &b); 00094 private: 00095 PriorityQueue<PathFinderNode*> openNodes_; // List of "open" nodes 00096 HashTable<HashTableKey_Pointer,PathFinderNode*> nodes_; // List of all nodes that this pathfinder uses 00097 MemoryPool<PathFinderNode> memoryPool_; // Memory pool used to speed up dynamic allocation 00098 00099 }; 00100 00101 #endif // __PathFinder_H__
Reproduction/republishing of any material on this site without permission is strictly prohibited.
