Index: source/simulation2/components/CCmpPathfinder.cpp =================================================================== --- source/simulation2/components/CCmpPathfinder.cpp +++ source/simulation2/components/CCmpPathfinder.cpp @@ -56,7 +56,6 @@ m_SameTurnMovesCount = 0; - m_VertexPathfinder = std::unique_ptr(new VertexPathfinder(m_MapSize, m_TerrainOnlyGrid)); m_LongPathfinder = std::unique_ptr(new LongPathfinder()); m_PathfinderHier = std::unique_ptr(new HierarchicalPathfinder()); @@ -191,7 +190,7 @@ void CCmpPathfinder::RenderSubmit(SceneCollector& collector) { - m_VertexPathfinder->RenderSubmit(collector); + m_VertexPathfinder.RenderSubmit(collector); m_PathfinderHier->RenderSubmit(collector); } @@ -202,7 +201,7 @@ void CCmpPathfinder::SetDebugOverlay(bool enabled) { - m_VertexPathfinder->SetDebugOverlay(enabled); + m_VertexPathfinder.SetDebugOverlay(enabled); m_LongPathfinder->SetDebugOverlay(enabled); } @@ -725,7 +724,7 @@ WaypointPath CCmpPathfinder::ComputeShortPath(const ShortPathRequest& request) const { - return m_VertexPathfinder->ComputeShortPath(request, CmpPtr(GetSystemEntity())); + return m_VertexPathfinder.ComputeShortPath(m_MapSize, m_TerrainOnlyGrid, request, CmpPtr(GetSystemEntity())); } // Async processing: @@ -768,7 +767,7 @@ for (size_t i = 0; i < shortRequests.size(); ++i) { const ShortPathRequest& req = shortRequests[i]; - WaypointPath path = m_VertexPathfinder->ComputeShortPath(req, CmpPtr(GetSystemEntity())); + WaypointPath path = m_VertexPathfinder.ComputeShortPath(m_MapSize, m_TerrainOnlyGrid, req, CmpPtr(GetSystemEntity())); CMessagePathResult msg(req.ticket, path); GetSimContext().GetComponentManager().PostMessage(req.notify, msg); } Index: source/simulation2/components/CCmpPathfinder_Common.h =================================================================== --- source/simulation2/components/CCmpPathfinder_Common.h +++ source/simulation2/components/CCmpPathfinder_Common.h @@ -37,11 +37,10 @@ #include "ps/CLogger.h" #include "renderer/TerrainOverlay.h" #include "simulation2/components/ICmpObstructionManager.h" - +#include "simulation2/helpers/VertexPathfinder.h" class HierarchicalPathfinder; class LongPathfinder; -class VertexPathfinder; class SceneCollector; class AtlasOverlay; @@ -97,7 +96,7 @@ GridUpdateInformation m_AIPathfinderDirtinessInformation; bool m_TerrainDirty; - std::unique_ptr m_VertexPathfinder; + VertexPathfinder m_VertexPathfinder; std::unique_ptr m_PathfinderHier; std::unique_ptr m_LongPathfinder; Index: source/simulation2/helpers/VertexPathfinder.h =================================================================== --- source/simulation2/helpers/VertexPathfinder.h +++ source/simulation2/helpers/VertexPathfinder.h @@ -72,7 +72,7 @@ class VertexPathfinder { public: - VertexPathfinder(const u16& mapSize, Grid* const & terrainOnlyGrid) : m_MapSize(mapSize), m_TerrainOnlyGrid(terrainOnlyGrid), m_DebugOverlay(false) {}; + VertexPathfinder() : m_DebugOverlay(false) {}; /** * Compute a precise path from the given point to the goal, and return the set of waypoints. @@ -81,7 +81,7 @@ * The path is restricted to a box of radius 'range' from the starting point. * Defined in CCmpPathfinder_Vertex.cpp */ - WaypointPath ComputeShortPath(const ShortPathRequest& request, CmpPtr cmpObstructionManager) const; + WaypointPath ComputeShortPath(const u16 mapSize, Grid* const& terrainOnlyGrid, const ShortPathRequest& request, CmpPtr cmpObstructionManager) const; void SetDebugOverlay(bool enabled) { m_DebugOverlay = enabled; } void RenderSubmit(SceneCollector& collector); @@ -92,10 +92,6 @@ void DebugRenderGraph(const CSimContext& simContext, const std::vector& vertexes, const std::vector& edges, const std::vector& edgeSquares) const; void DebugRenderEdges(const CSimContext& simContext, bool visible, CFixedVector2D curr, CFixedVector2D npos) const; - // References to the Pathfinder for convenience. - const u16& m_MapSize; - Grid* const & m_TerrainOnlyGrid; - std::atomic m_DebugOverlay; mutable std::vector m_DebugOverlayShortPathLines; Index: source/simulation2/helpers/VertexPathfinder.cpp =================================================================== --- source/simulation2/helpers/VertexPathfinder.cpp +++ source/simulation2/helpers/VertexPathfinder.cpp @@ -510,7 +510,7 @@ } }; -WaypointPath VertexPathfinder::ComputeShortPath(const ShortPathRequest& request, CmpPtr cmpObstructionManager) const +WaypointPath VertexPathfinder::ComputeShortPath(const u16 mapSize, Grid* const& terrainOnlyGrid, const ShortPathRequest& request, CmpPtr cmpObstructionManager) const { PROFILE2("ComputeShortPath"); @@ -625,9 +625,9 @@ // Add terrain obstructions { u16 i0, j0, i1, j1; - Pathfinding::NearestNavcell(rangeXMin, rangeZMin, i0, j0, m_MapSize*Pathfinding::NAVCELLS_PER_TILE, m_MapSize*Pathfinding::NAVCELLS_PER_TILE); - Pathfinding::NearestNavcell(rangeXMax, rangeZMax, i1, j1, m_MapSize*Pathfinding::NAVCELLS_PER_TILE, m_MapSize*Pathfinding::NAVCELLS_PER_TILE); - AddTerrainEdges(m_Edges, m_Vertexes, i0, j0, i1, j1, request.passClass, *m_TerrainOnlyGrid); + Pathfinding::NearestNavcell(rangeXMin, rangeZMin, i0, j0, mapSize * Pathfinding::NAVCELLS_PER_TILE, mapSize * Pathfinding::NAVCELLS_PER_TILE); + Pathfinding::NearestNavcell(rangeXMax, rangeZMax, i1, j1, mapSize * Pathfinding::NAVCELLS_PER_TILE, mapSize * Pathfinding::NAVCELLS_PER_TILE); + AddTerrainEdges(m_Edges, m_Vertexes, i0, j0, i1, j1, request.passClass, *terrainOnlyGrid); } // Clip out vertices that are inside an edgeSquare (i.e. trivially unreachable)