diff --git a/src/xrAICore/Navigation/a_star.h b/src/xrAICore/Navigation/a_star.h index 95a7c2e34ad..8f2e4e087e2 100644 --- a/src/xrAICore/Navigation/a_star.h +++ b/src/xrAICore/Navigation/a_star.h @@ -12,16 +12,13 @@ #include "xrAICore/Navigation/data_storage_constructor.h" #include "xrAICore/Navigation/dijkstra.h" -namespace AStar -{ -template -struct ByDistType +template +struct AStarVertexData { template - struct VertexData : - Dijkstra::template ByDistType<_dist_type>::template VertexData + struct VertexData : TVertexData::template VertexData { - typedef _dist_type _dist_type; + typedef _dist_type _dist_type; _dist_type _g; _dist_type _h; @@ -30,26 +27,25 @@ struct ByDistType _dist_type &h() { return _h; } }; }; -} template < typename _dist_type, typename _priority_queue, typename _vertex_manager, typename _vertex_allocator, - typename TCompoundVertex = EmptyVertexData, bool euclidian_heuristics = true, typename _data_storage_base = CVertexPath, - typename _iteration_type = u32 + typename _iteration_type = u32, + typename TVertexData = EmptyVertexData > class CAStar : public CDijkstra< _dist_type, _priority_queue, _vertex_manager, _vertex_allocator, - TCompoundVertex, euclidian_heuristics, _data_storage_base, - _iteration_type + _iteration_type, + AStarVertexData<_dist_type, TVertexData> > { protected: @@ -58,12 +54,12 @@ template < _priority_queue, _vertex_manager, _vertex_allocator, - TCompoundVertex, euclidian_heuristics, _data_storage_base, - _iteration_type + _iteration_type, + AStarVertexData<_dist_type, TVertexData> > inherited; - typedef TCompoundVertex CGraphVertex; + typedef typename inherited::CGraphVertex CGraphVertex; typedef typename CGraphVertex::_dist_type _dist_type; typedef typename CGraphVertex::_index_type _index_type; diff --git a/src/xrAICore/Navigation/a_star_inline.h b/src/xrAICore/Navigation/a_star_inline.h index 40ca0ee52a4..2ff81bdd480 100644 --- a/src/xrAICore/Navigation/a_star_inline.h +++ b/src/xrAICore/Navigation/a_star_inline.h @@ -14,10 +14,10 @@ typename _priority_queue,\ typename _vertex_manager,\ typename _vertex_allocator,\ - typename TCompoundVertex,\ bool euclidian_heuristics,\ typename _data_storage_base,\ - typename _iteration_type\ + typename _iteration_type,\ + typename TVertexData\ > #define CSAStar CAStar<\ @@ -25,10 +25,10 @@ _priority_queue,\ _vertex_manager,\ _vertex_allocator,\ - TCompoundVertex,\ euclidian_heuristics,\ _data_storage_base,\ - _iteration_type\ + _iteration_type,\ + TVertexData\ > TEMPLATE_SPECIALIZATION diff --git a/src/xrAICore/Navigation/data_storage_constructor.h b/src/xrAICore/Navigation/data_storage_constructor.h index cdf6cae9591..a08f3ab9f6e 100644 --- a/src/xrAICore/Navigation/data_storage_constructor.h +++ b/src/xrAICore/Navigation/data_storage_constructor.h @@ -9,7 +9,11 @@ #pragma once struct EmptyVertexData -{}; +{ + template // result mixin type + struct VertexData + {}; +}; template struct CompoundVertex : Components::template VertexData>... diff --git a/src/xrAICore/Navigation/dijkstra.h b/src/xrAICore/Navigation/dijkstra.h index d0dc55ce488..a00938f213e 100644 --- a/src/xrAICore/Navigation/dijkstra.h +++ b/src/xrAICore/Navigation/dijkstra.h @@ -11,48 +11,47 @@ #include "xrAICore/Navigation/vertex_path.h" #include "xrAICore/Navigation/data_storage_constructor.h" -namespace Dijkstra +template +struct DijkstraVertexData { - template - struct ByDistType + template + struct VertexData : TVertexData::template VertexData { - template - struct VertexData - { - typedef _dist_type _dist_type; + typedef _dist_type _dist_type; - _dist_type _f; - TCompoundVertex *_back; + _dist_type _f; + TCompoundVertex *_back; - _dist_type &f() { return _f; } - const _dist_type &f() const { return _f; } - TCompoundVertex *&back() { return _back; } - }; - }; -} + _dist_type &f() { return _f; } + const _dist_type &f() const { return _f; } + TCompoundVertex *&back() { return _back; } + }; +}; template < typename _dist_type, typename _priority_queue, typename _vertex_manager, typename _vertex_allocator, - typename TCompoundVertex = EmptyVertexData, bool euclidian_heuristics = true, typename _data_storage_base = CVertexPath, - typename _iteration_type = u32 + typename _iteration_type = u32, + typename TVertexData = EmptyVertexData > class CDijkstra { public: + using CompoundVertex = CompoundVertex, + _priority_queue, _vertex_manager, _vertex_allocator, _data_storage_base>; typedef CDataStorageConstructor< _priority_queue, // algorithm _vertex_manager, // manager _data_storage_base, // builder _vertex_allocator, // allocator - TCompoundVertex + CompoundVertex > CDataStorage; protected: - typedef TCompoundVertex CGraphVertex; + typedef CompoundVertex CGraphVertex; typedef typename CGraphVertex::_dist_type _dist_type; typedef typename CGraphVertex::_index_type _index_type; diff --git a/src/xrAICore/Navigation/dijkstra_inline.h b/src/xrAICore/Navigation/dijkstra_inline.h index 2b37cf24d84..0e5d37a0927 100644 --- a/src/xrAICore/Navigation/dijkstra_inline.h +++ b/src/xrAICore/Navigation/dijkstra_inline.h @@ -14,10 +14,10 @@ typename _priority_queue,\ typename _vertex_manager,\ typename _vertex_allocator,\ - typename TCompoundVertex,\ bool euclidian_heuristics,\ typename _data_storage_base,\ - typename _iteration_type\ + typename _iteration_type,\ + typename TVertexData\ > #define CSDijkstra CDijkstra<\ @@ -25,10 +25,10 @@ _priority_queue,\ _vertex_manager,\ _vertex_allocator,\ - TCompoundVertex,\ euclidian_heuristics,\ _data_storage_base,\ - _iteration_type\ + _iteration_type,\ + TVertexData\ > TEMPLATE_SPECIALIZATION diff --git a/src/xrAICore/Navigation/graph_engine.h b/src/xrAICore/Navigation/graph_engine.h index f82cb58b384..6b26db52f1b 100644 --- a/src/xrAICore/Navigation/graph_engine.h +++ b/src/xrAICore/Navigation/graph_engine.h @@ -55,45 +55,33 @@ class CGraphEngine using CStringVertexAllocator = CVertexAllocatorFixed<1024>; #endif using AlgorithmStorage = CVertexPath; - using AlgorithmVertexData = AStar::template ByDistType<_dist_type>; - using AlgorithmVertex = CompoundVertex; - using CAlgorithm = CAStar< + using CAlgorithm = CAStar< _dist_type, CPriorityQueue, CVertexManager, CVertexAllocator, - AlgorithmVertex, true, AlgorithmStorage>; #ifndef AI_COMPILER using SolverAlgorithmStorage = CEdgePath<_solver_edge_type, true>; - using SolverAlgorithmVertexData = AStar::template ByDistType<_solver_dist_type>; - using SolverAlgorithmVertex = CompoundVertex; using CSolverAlgorithm = CAStar< _solver_dist_type, CSolverPriorityQueue, CSolverVertexManager, CSolverVertexAllocator, - SolverAlgorithmVertex, true, SolverAlgorithmStorage>; using _string_dist_type = float; using StringAlgorithmStorage = AlgorithmStorage; - using StringAlgorithmVertexData = AStar::template ByDistType<_string_dist_type>; - using StringAlgorithmVertex = CompoundVertex; using CStringAlgorithm = CAStar< _string_dist_type, CStringPriorityQueue, CStringVertexManager, CStringVertexAllocator, - StringAlgorithmVertex, true, - AlgorithmStorage>; + StringAlgorithmStorage>; #endif // AI_COMPILER CAlgorithm *m_algorithm;