1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#ifndef QTPFS_PATHMANAGER_HDR
#define QTPFS_PATHMANAGER_HDR
#include <map>
#include <list>
#include <vector>
#include "Sim/Path/IPathManager.h"
#include "NodeLayer.hpp"
#include "PathCache.hpp"
#include "PathSearch.hpp"
struct MoveData;
struct SRectangle;
class CSolidObject;
namespace QTPFS {
struct QTNode;
class PathManager: public IPathManager {
public:
PathManager();
~PathManager();
boost::uint32_t GetPathCheckSum() const { return pfsCheckSum; }
void TerrainChange(unsigned int x1, unsigned int z1, unsigned int x2, unsigned int z2);
void Update();
void UpdatePath(const CSolidObject* owner, unsigned int pathID);
void DeletePath(unsigned int pathID);
unsigned int RequestPath(
const MoveData* moveData,
const float3& sourcePos,
const float3& targetPos,
float radius,
CSolidObject* object,
bool synced
);
float3 NextWayPoint(
unsigned int pathID,
float3 point,
float radius = 0.0f,
int = 0, // numRetries
int = 0, // ownerID
bool synced = true
);
void GetPathWayPoints(
unsigned int pathID,
std::vector<float3>& points,
std::vector<int>& starts
) const;
static NodeLayer* GetSerializingNodeLayer() { return serializingNodeLayer; }
static const unsigned int MAX_UPDATE_DELAY = 10;
static const unsigned int MAX_TEAM_SEARCHES = 10;
static const unsigned int NUM_SPEEDMOD_BINS = 20;
static const float MIN_SPEEDMOD_VALUE;
static const float MAX_SPEEDMOD_VALUE;
private:
void Load();
boost::uint64_t GetMemFootPrint() const;
typedef void (PathManager::*MemberFunc)(
unsigned int threadNum,
unsigned int numThreads,
const SRectangle& rect,
bool wantTesselation
);
typedef std::map<unsigned int, unsigned int> PathTypeMap;
typedef std::map<unsigned int, unsigned int>::iterator PathTypeMapIt;
typedef std::map<unsigned int, PathSearchTrace::Execution*> PathTraceMap;
typedef std::map<unsigned int, PathSearchTrace::Execution*>::iterator PathTraceMapIt;
typedef std::map<boost::uint64_t, IPath*> SharedPathMap;
typedef std::map<boost::uint64_t, IPath*>::iterator SharedPathMapIt;
typedef std::list<IPathSearch*> PathSearchList;
typedef std::list<IPathSearch*>::iterator PathSearchListIt;
void SpawnBoostThreads(MemberFunc f, const SRectangle& r, bool b);
void InitNodeLayersThreaded(const SRectangle& rect, bool haveCacheDir);
void UpdateNodeLayersThreaded(const SRectangle& rect);
void InitNodeLayersThread(
unsigned int threadNum,
unsigned int numThreads,
const SRectangle& rect,
bool haveCacheDir
);
void UpdateNodeLayersThread(
unsigned int threadNum,
unsigned int numThreads,
const SRectangle& rect,
bool wantTesselation
);
void InitNodeLayer(unsigned int layerNum, const SRectangle& rect);
void UpdateNodeLayer(unsigned int layerNum, const SRectangle& r, bool wantTesselation);
void ExecuteQueuedSearches(unsigned int pathType);
void QueueDeadPathSearches(unsigned int pathType);
unsigned int QueueSearch(
const IPath* oldPath,
const CSolidObject* object,
const MoveData* moveData,
const float3& sourcePoint,
const float3& targetPoint,
const float radius,
const bool synced
);
void ExecuteSearch(
PathSearchList& searches,
PathSearchListIt& searchesIt,
NodeLayer& nodeLayer,
PathCache& pathCache,
unsigned int pathType
);
std::string GetCacheDirName(boost::uint32_t mapCheckSum, boost::uint32_t modCheckSum) const;
void Serialize(const std::string& cacheFileDir);
std::vector<NodeLayer> nodeLayers;
std::vector<QTNode*> nodeTrees;
std::vector<PathCache> pathCaches;
std::vector< std::list<IPathSearch*> > pathSearches;
std::map<unsigned int, unsigned int> pathTypes;
std::map<unsigned int, PathSearchTrace::Execution*> pathTraces;
// maps "hashes" of executed searches to the found paths
std::map<boost::uint64_t, IPath*> sharedPaths;
std::vector<unsigned int> numCurrExecutedSearches;
std::vector<unsigned int> numPrevExecutedSearches;
static NodeLayer* serializingNodeLayer;
unsigned int searchStateOffset;
unsigned int numTerrainChanges;
unsigned int numPathRequests;
unsigned int maxNumLeafNodes;
boost::uint32_t pfsCheckSum;
};
};
#endif
|