Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/helpers/HierarchicalPathfinder.h
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | public: | ||||
* In the case of a non-point reachable goal, it is replaced with a point goal | * In the case of a non-point reachable goal, it is replaced with a point goal | ||||
* at the reachable navcell of the goal which is nearest to the starting navcell. | * at the reachable navcell of the goal which is nearest to the starting navcell. | ||||
* | * | ||||
* @returns true if the goal was reachable, false otherwise. | * @returns true if the goal was reachable, false otherwise. | ||||
*/ | */ | ||||
bool MakeGoalReachable(u16 i0, u16 j0, PathGoal& goal, pass_class_t passClass) const; | bool MakeGoalReachable(u16 i0, u16 j0, PathGoal& goal, pass_class_t passClass) const; | ||||
/** | /** | ||||
* Updates @p i, @p j (which is assumed to be an impassable navcell) | * Updates @p i, @p j (which is assumed to be an impassable navcell) | ||||
Freagarach: -`.` | |||||
* to the nearest passable navcell. | * to the nearest passable navcell. | ||||
*/ | */ | ||||
void FindNearestPassableNavcell(u16& i, u16& j, pass_class_t passClass) const; | void FindNearestPassableNavcell(u16& i, u16& j, pass_class_t passClass) const; | ||||
/** | /** | ||||
* Generates the connectivity grid associated with the given pass_class | * Generates the connectivity grid associated with the given pass_class | ||||
*/ | */ | ||||
Grid<u16> GetConnectivityGrid(pass_class_t passClass) const; | Grid<u16> GetConnectivityGrid(pass_class_t passClass) const; | ||||
/** | |||||
* Find all regions reachable from the given region by a unit with the specified pass class. | |||||
*/ | |||||
template<typename Ordering> | |||||
void FindReachableRegions(RegionID from, std::set<RegionID, Ordering>& reachable, pass_class_t passClass) const; | |||||
Not Done Inline ActionsIs there a reason why you moved this above? wraitii: Is there a reason why you moved this above? | |||||
Done Inline ActionsMaking it public. However, I don't need to use it if I use GetGlobalRegion. causative: Making it public. However, I don't need to use it if I use GetGlobalRegion. | |||||
pass_class_t GetPassabilityClass(const std::string& name) const | pass_class_t GetPassabilityClass(const std::string& name) const | ||||
{ | { | ||||
auto it = m_PassClassMasks.find(name); | auto it = m_PassClassMasks.find(name); | ||||
if (it != m_PassClassMasks.end()) | if (it != m_PassClassMasks.end()) | ||||
return it->second; | return it->second; | ||||
LOGERROR("Invalid passability class name '%s'", name.c_str()); | LOGERROR("Invalid passability class name '%s'", name.c_str()); | ||||
return 0; | return 0; | ||||
Show All 39 Lines | #endif | ||||
typedef std::map<RegionID, std::set<RegionID> > EdgesMap; | typedef std::map<RegionID, std::set<RegionID> > EdgesMap; | ||||
void ComputeNeighbors(EdgesMap& edges, Chunk& a, Chunk& b, bool transpose, bool opposite) const; | void ComputeNeighbors(EdgesMap& edges, Chunk& a, Chunk& b, bool transpose, bool opposite) const; | ||||
void RecomputeAllEdges(pass_class_t passClass, EdgesMap& edges); | void RecomputeAllEdges(pass_class_t passClass, EdgesMap& edges); | ||||
void UpdateEdges(u8 ci, u8 cj, pass_class_t passClass, EdgesMap& edges); | void UpdateEdges(u8 ci, u8 cj, pass_class_t passClass, EdgesMap& edges); | ||||
void UpdateGlobalRegions(const std::map<pass_class_t, std::vector<RegionID> >& needNewGlobalRegionMap); | void UpdateGlobalRegions(const std::map<pass_class_t, std::vector<RegionID> >& needNewGlobalRegionMap); | ||||
/** | |||||
* Returns all reachable regions, optionally ordered in a specific manner. | |||||
*/ | |||||
template<typename Ordering> | |||||
void FindReachableRegions(RegionID from, std::set<RegionID, Ordering>& reachable, pass_class_t passClass) const; | |||||
struct SortByCenterToPoint | struct SortByCenterToPoint | ||||
{ | { | ||||
SortByCenterToPoint(u16 i, u16 j): gi(i), gj(j) {}; | SortByCenterToPoint(u16 i, u16 j): gi(i), gj(j) {}; | ||||
bool operator()(const HierarchicalPathfinder::RegionID& a, const HierarchicalPathfinder::RegionID& b) const | bool operator()(const HierarchicalPathfinder::RegionID& a, const HierarchicalPathfinder::RegionID& b) const | ||||
{ | { | ||||
if (a.DistanceTo(gi, gj) < b.DistanceTo(gi, gj)) | if (a.DistanceTo(gi, gj) < b.DistanceTo(gi, gj)) | ||||
return true; | return true; | ||||
if (a.DistanceTo(gi, gj) > b.DistanceTo(gi, gj)) | if (a.DistanceTo(gi, gj) > b.DistanceTo(gi, gj)) | ||||
▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
-.