Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpPathfinder.cpp
Show First 20 Lines • Show All 726 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
return m_VertexPathfinder->ComputeShortPath(request, CmpPtr<ICmpObstructionManager>(GetSystemEntity())); | return m_VertexPathfinder->ComputeShortPath(request, CmpPtr<ICmpObstructionManager>(GetSystemEntity())); | ||||
} | } | ||||
// Async processing: | // Async processing: | ||||
void CCmpPathfinder::FinishAsyncRequests() | void CCmpPathfinder::FinishAsyncRequests() | ||||
{ | { | ||||
PROFILE2("Finish Async Requests"); | PROFILE3("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 | ||||
std::vector<LongPathRequest> longRequests; | std::vector<LongPathRequest> longRequests; | ||||
m_LongPathRequests.swap(longRequests); | m_LongPathRequests.swap(longRequests); | ||||
std::vector<ShortPathRequest> shortRequests; | std::vector<ShortPathRequest> shortRequests; | ||||
m_ShortPathRequests.swap(shortRequests); | m_ShortPathRequests.swap(shortRequests); | ||||
// TODO: we should only compute one path per entity per turn | // TODO: we should only compute one path per entity per turn | ||||
// TODO: this computation should be done incrementally, spread | // TODO: this computation should be done incrementally, spread | ||||
// across multiple frames (or even multiple turns) | // across multiple frames (or even multiple turns) | ||||
ProcessLongRequests(longRequests); | ProcessLongRequests(longRequests); | ||||
ProcessShortRequests(shortRequests); | ProcessShortRequests(shortRequests); | ||||
} | } | ||||
void CCmpPathfinder::ProcessLongRequests(const std::vector<LongPathRequest>& longRequests) | void CCmpPathfinder::ProcessLongRequests(const std::vector<LongPathRequest>& longRequests) | ||||
{ | { | ||||
PROFILE2("Process Long Requests"); | PROFILE3("Process Long Requests"); | ||||
for (size_t i = 0; i < longRequests.size(); ++i) | for (size_t i = 0; i < longRequests.size(); ++i) | ||||
{ | { | ||||
const LongPathRequest& req = longRequests[i]; | const LongPathRequest& req = longRequests[i]; | ||||
WaypointPath path; | WaypointPath path; | ||||
ComputePath(req.x0, req.z0, req.goal, req.passClass, path); | ComputePath(req.x0, req.z0, req.goal, req.passClass, path); | ||||
CMessagePathResult msg(req.ticket, path); | CMessagePathResult msg(req.ticket, path); | ||||
GetSimContext().GetComponentManager().PostMessage(req.notify, msg); | GetSimContext().GetComponentManager().PostMessage(req.notify, msg); | ||||
} | } | ||||
} | } | ||||
void CCmpPathfinder::ProcessShortRequests(const std::vector<ShortPathRequest>& shortRequests) | void CCmpPathfinder::ProcessShortRequests(const std::vector<ShortPathRequest>& shortRequests) | ||||
{ | { | ||||
PROFILE2("Process Short Requests"); | PROFILE3("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(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); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator