Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpPathfinder.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | void CCmpPathfinder::Init(const CParamNode& UNUSED(paramNode)) | ||||
FlushAIPathfinderDirtinessInformation(); | FlushAIPathfinderDirtinessInformation(); | ||||
m_NextAsyncTicket = 1; | m_NextAsyncTicket = 1; | ||||
m_AtlasOverlay = NULL; | m_AtlasOverlay = NULL; | ||||
m_SameTurnMovesCount = 0; | m_SameTurnMovesCount = 0; | ||||
m_VertexPathfinder = std::unique_ptr<VertexPathfinder>(new VertexPathfinder(m_MapSize, m_TerrainOnlyGrid)); | |||||
m_LongPathfinder = std::unique_ptr<LongPathfinder>(new LongPathfinder()); | m_LongPathfinder = std::unique_ptr<LongPathfinder>(new LongPathfinder()); | ||||
m_PathfinderHier = std::unique_ptr<HierarchicalPathfinder>(new HierarchicalPathfinder()); | m_PathfinderHier = std::unique_ptr<HierarchicalPathfinder>(new HierarchicalPathfinder()); | ||||
// Register Relax NG validator | // Register Relax NG validator | ||||
CXeromyces::AddValidator(g_VFS, "pathfinder", "simulation/data/pathfinder.rng"); | CXeromyces::AddValidator(g_VFS, "pathfinder", "simulation/data/pathfinder.rng"); | ||||
// Since this is used as a system component (not loaded from an entity template), | // Since this is used as a system component (not loaded from an entity template), | ||||
// we can't use the real paramNode (it won't get handled properly when deserializing), | // we can't use the real paramNode (it won't get handled properly when deserializing), | ||||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | void CCmpPathfinder::HandleMessage(const CMessage& msg, bool UNUSED(global)) | ||||
case MT_TurnStart: | case MT_TurnStart: | ||||
m_SameTurnMovesCount = 0; | m_SameTurnMovesCount = 0; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
void CCmpPathfinder::RenderSubmit(SceneCollector& collector) | void CCmpPathfinder::RenderSubmit(SceneCollector& collector) | ||||
{ | { | ||||
m_VertexPathfinder->RenderSubmit(collector); | m_VertexPathfinder.RenderSubmit(collector); | ||||
m_PathfinderHier->RenderSubmit(collector); | m_PathfinderHier->RenderSubmit(collector); | ||||
} | } | ||||
void CCmpPathfinder::SetDebugPath(entity_pos_t x0, entity_pos_t z0, const PathGoal& goal, pass_class_t passClass) | void CCmpPathfinder::SetDebugPath(entity_pos_t x0, entity_pos_t z0, const PathGoal& goal, pass_class_t passClass) | ||||
{ | { | ||||
m_LongPathfinder->SetDebugPath(*m_PathfinderHier, x0, z0, goal, passClass); | m_LongPathfinder->SetDebugPath(*m_PathfinderHier, x0, z0, goal, passClass); | ||||
} | } | ||||
void CCmpPathfinder::SetDebugOverlay(bool enabled) | void CCmpPathfinder::SetDebugOverlay(bool enabled) | ||||
{ | { | ||||
m_VertexPathfinder->SetDebugOverlay(enabled); | m_VertexPathfinder.SetDebugOverlay(enabled); | ||||
m_LongPathfinder->SetDebugOverlay(enabled); | m_LongPathfinder->SetDebugOverlay(enabled); | ||||
} | } | ||||
void CCmpPathfinder::SetHierDebugOverlay(bool enabled) | void CCmpPathfinder::SetHierDebugOverlay(bool enabled) | ||||
{ | { | ||||
m_PathfinderHier->SetDebugOverlay(enabled, &GetSimContext()); | m_PathfinderHier->SetDebugOverlay(enabled, &GetSimContext()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 506 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
ShortPathRequest req = { m_NextAsyncTicket++, x0, z0, clearance, range, goal, passClass, avoidMovingUnits, group, notify }; | ShortPathRequest req = { m_NextAsyncTicket++, x0, z0, clearance, range, goal, passClass, avoidMovingUnits, group, notify }; | ||||
m_ShortPathRequests.push_back(req); | m_ShortPathRequests.push_back(req); | ||||
return req.ticket; | return req.ticket; | ||||
} | } | ||||
WaypointPath CCmpPathfinder::ComputeShortPath(const ShortPathRequest& request) const | WaypointPath CCmpPathfinder::ComputeShortPath(const ShortPathRequest& request) const | ||||
{ | { | ||||
return m_VertexPathfinder->ComputeShortPath(request, CmpPtr<ICmpObstructionManager>(GetSystemEntity())); | return m_VertexPathfinder.ComputeShortPath(m_MapSize, m_TerrainOnlyGrid, request, CmpPtr<ICmpObstructionManager>(GetSystemEntity())); | ||||
} | } | ||||
// Async processing: | // Async processing: | ||||
void CCmpPathfinder::FinishAsyncRequests() | void CCmpPathfinder::FinishAsyncRequests() | ||||
{ | { | ||||
PROFILE2("Finish Async Requests"); | PROFILE2("Finish Async Requests"); | ||||
// Save the request queue in case it gets modified while iterating | // Save the request queue in case it gets modified while iterating | ||||
Show All 26 Lines | |||||
} | } | ||||
void CCmpPathfinder::ProcessShortRequests(const std::vector<ShortPathRequest>& shortRequests) | void CCmpPathfinder::ProcessShortRequests(const std::vector<ShortPathRequest>& shortRequests) | ||||
{ | { | ||||
PROFILE2("Process Short Requests"); | PROFILE2("Process Short Requests"); | ||||
for (size_t i = 0; i < shortRequests.size(); ++i) | for (size_t i = 0; i < shortRequests.size(); ++i) | ||||
{ | { | ||||
const ShortPathRequest& req = shortRequests[i]; | const ShortPathRequest& req = shortRequests[i]; | ||||
WaypointPath path = m_VertexPathfinder->ComputeShortPath(req, CmpPtr<ICmpObstructionManager>(GetSystemEntity())); | WaypointPath path = m_VertexPathfinder.ComputeShortPath(m_MapSize, m_TerrainOnlyGrid, req, CmpPtr<ICmpObstructionManager>(GetSystemEntity())); | ||||
CMessagePathResult msg(req.ticket, path); | CMessagePathResult msg(req.ticket, path); | ||||
GetSimContext().GetComponentManager().PostMessage(req.notify, msg); | GetSimContext().GetComponentManager().PostMessage(req.notify, msg); | ||||
} | } | ||||
} | } | ||||
void CCmpPathfinder::ProcessSameTurnMoves() | void CCmpPathfinder::ProcessSameTurnMoves() | ||||
{ | { | ||||
if (!m_LongPathRequests.empty()) | if (!m_LongPathRequests.empty()) | ||||
▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator