Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/helpers/VertexPathfinder.h
/* Copyright (C) 2019 Wildfire Games. | /* Copyright (C) 2020 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | private: | ||||
void DebugRenderGoal(const CSimContext& simContext, const PathGoal& goal) const; | void DebugRenderGoal(const CSimContext& simContext, const PathGoal& goal) const; | ||||
void DebugRenderGraph(const CSimContext& simContext, const std::vector<Vertex>& vertexes, const std::vector<Edge>& edges, const std::vector<Square>& edgeSquares) const; | void DebugRenderGraph(const CSimContext& simContext, const std::vector<Vertex>& vertexes, const std::vector<Edge>& edges, const std::vector<Square>& edgeSquares) const; | ||||
void DebugRenderEdges(const CSimContext& simContext, bool visible, CFixedVector2D curr, CFixedVector2D npos) const; | void DebugRenderEdges(const CSimContext& simContext, bool visible, CFixedVector2D curr, CFixedVector2D npos) const; | ||||
// References to the Pathfinder for convenience. | // References to the Pathfinder for convenience. | ||||
const u16& m_MapSize; | const u16& m_MapSize; | ||||
Grid<NavcellData>* const & m_TerrainOnlyGrid; | Grid<NavcellData>* const & m_TerrainOnlyGrid; | ||||
std::atomic<bool> m_DebugOverlay; | bool m_DebugOverlay; | ||||
mutable std::vector<SOverlayLine> m_DebugOverlayShortPathLines; | static thread_local std::vector<SOverlayLine> m_DebugOverlayShortPathLines; | ||||
static thread_local std::mutex m_DebugMutex; | |||||
// These vectors are expensive to recreate on every call, so we cache them here. | // These vectors are expensive to recreate on every call, so we cache them here. | ||||
// They are made mutable to allow using them in the otherwise const ComputeShortPath. | |||||
mutable std::vector<Edge> m_EdgesUnaligned; | static thread_local std::vector<Edge> m_EdgesUnaligned; | ||||
mutable std::vector<EdgeAA> m_EdgesLeft; | static thread_local std::vector<EdgeAA> m_EdgesLeft; | ||||
mutable std::vector<EdgeAA> m_EdgesRight; | static thread_local std::vector<EdgeAA> m_EdgesRight; | ||||
mutable std::vector<EdgeAA> m_EdgesBottom; | static thread_local std::vector<EdgeAA> m_EdgesBottom; | ||||
mutable std::vector<EdgeAA> m_EdgesTop; | static thread_local std::vector<EdgeAA> m_EdgesTop; | ||||
// List of obstruction vertexes (plus start/end points); we'll try to find paths through | // List of obstruction vertexes (plus start/end points); we'll try to find paths through | ||||
// the graph defined by these vertexes. | // the graph defined by these vertexes. | ||||
mutable std::vector<Vertex> m_Vertexes; | static thread_local std::vector<Vertex> m_Vertexes; | ||||
// List of collision edges - paths must never cross these. | // List of collision edges - paths must never cross these. | ||||
// (Edges are one-sided so intersections are fine in one direction, but not the other direction.) | // (Edges are one-sided so intersections are fine in one direction, but not the other direction.) | ||||
mutable std::vector<Edge> m_Edges; | static thread_local std::vector<Edge> m_Edges; | ||||
mutable std::vector<Square> m_EdgeSquares; // Axis-aligned squares; equivalent to 4 edges. | static thread_local std::vector<Square> m_EdgeSquares; // Axis-aligned squares; equivalent to 4 edges. | ||||
}; | }; | ||||
#endif // INCLUDED_VERTEXPATHFINDER | #endif // INCLUDED_VERTEXPATHFINDER |
Wildfire Games · Phabricator