Skip to content

Commit c0a47e2

Browse files
author
nitrocaster
committed
Merge CDataStorageDoubleLinkedList into CDataStorageBucketList.
1 parent c4290bf commit c0a47e2

File tree

6 files changed

+40
-251
lines changed

6 files changed

+40
-251
lines changed

src/xrAICore/Navigation/data_storage_bucket_list.h

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
#pragma once
1010

11-
#include "xrAICore/Navigation/data_storage_double_linked_list.h"
12-
1311
template <
1412
typename _path_id_type,
1513
typename _bucket_id_type,
@@ -19,30 +17,38 @@ template <
1917
struct CDataStorageBucketList {
2018

2119
template <template <typename _T> class T1>
22-
struct BucketList {
20+
struct BucketList
21+
{
2322
template<typename T2>
24-
struct _vertex : public T1<T2> {
25-
_path_id_type m_path_id;
26-
_bucket_id_type m_bucket_id;
23+
struct _vertex : public T1<T2>
24+
{
25+
T2 *_next;
26+
T2 *_prev;
27+
_path_id_type m_path_id;
28+
_bucket_id_type m_bucket_id;
29+
T2 *&next() { return _next; }
30+
T2 *&prev() { return _prev; }
2731
};
2832
};
2933

3034
template <
3135
typename _data_storage,
3236
template <typename _T> class _vertex = CEmptyClassTemplate
3337
>
34-
class CDataStorage : public CDataStorageDoubleLinkedList<false>::CDataStorage<_data_storage,BucketList<_vertex>::_vertex> {
38+
class CDataStorage : public _data_storage::template CDataStorage<BucketList<_vertex>::_vertex>
39+
{
3540
public:
36-
typedef typename CDataStorageDoubleLinkedList<false>::CDataStorage<
37-
_data_storage,
38-
BucketList<_vertex>::_vertex
39-
> inherited;
40-
typedef typename inherited::inherited inherited_base;
41-
typedef typename inherited::CGraphVertex CGraphVertex;
42-
typedef typename CGraphVertex::_dist_type _dist_type;
43-
typedef typename CGraphVertex::_index_type _index_type;
41+
typedef typename _data_storage::template CDataStorage<BucketList<_vertex>::_vertex> inherited;
42+
typedef typename inherited::CGraphVertex CGraphVertex;
43+
typedef typename CGraphVertex::_dist_type _dist_type;
44+
typedef typename CGraphVertex::_index_type _index_type;
4445

4546
protected:
47+
_dist_type m_max_distance;
48+
CGraphVertex m_list_data[2];
49+
CGraphVertex *m_list_head;
50+
CGraphVertex *m_list_tail;
51+
_dist_type m_switch_factor;
4652
_dist_type m_min_bucket_value;
4753
_dist_type m_max_bucket_value;
4854
CGraphVertex *m_buckets[bucket_count];
@@ -53,6 +59,7 @@ struct CDataStorageBucketList {
5359
virtual ~CDataStorage ();
5460
IC void init ();
5561
IC void add_best_closed ();
62+
IC void set_switch_factor (const _dist_type _switch_factor);
5663
IC bool is_opened_empty ();
5764
IC u32 compute_bucket_id (CGraphVertex &vertex) const;
5865
IC void verify_buckets () const;

src/xrAICore/Navigation/data_storage_bucket_list_inline.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ TEMPLATE_SPECIALIZATION
2626
IC CBucketList::CDataStorage (const u32 vertex_count) :
2727
inherited(vertex_count)
2828
{
29+
m_max_distance = _dist_type(-1);
30+
m_switch_factor = _dist_type(1);
2931
m_min_bucket_value = _dist_type(0);
3032
m_max_bucket_value = _dist_type(1000);
3133
ZeroMemory (m_buckets,bucket_count*sizeof(CGraphVertex*));
@@ -40,6 +42,12 @@ TEMPLATE_SPECIALIZATION
4042
IC void CBucketList::init ()
4143
{
4244
inherited::init ();
45+
ZeroMemory (m_list_data,2*sizeof(CGraphVertex));
46+
m_list_head = m_list_data;
47+
m_list_tail = m_list_data + 1;
48+
m_list_head->next() = m_list_tail;
49+
m_list_tail->f() = m_max_distance;
50+
m_list_tail->prev() = m_list_head;
4351
m_min_bucket_id = bucket_count;
4452
if (clear_buckets)
4553
ZeroMemory (m_buckets,bucket_count*sizeof(CGraphVertex*));
@@ -49,7 +57,15 @@ TEMPLATE_SPECIALIZATION
4957
IC void CBucketList::add_best_closed ()
5058
{
5159
VERIFY (!is_opened_empty());
52-
inherited_base::add_closed (*m_buckets[m_min_bucket_id]);
60+
inherited::add_closed (*m_buckets[m_min_bucket_id]);
61+
}
62+
63+
TEMPLATE_SPECIALIZATION
64+
IC void CBucketList::set_switch_factor (const _dist_type _switch_factor)
65+
{
66+
if (!sorted)
67+
NODEFAULT;
68+
m_switch_factor = _switch_factor;
5369
}
5470

5571
TEMPLATE_SPECIALIZATION
@@ -175,7 +191,7 @@ TEMPLATE_SPECIALIZATION
175191
IC void CBucketList::add_opened (CGraphVertex &vertex)
176192
{
177193
// ai().m_visited_nodes.push_back (vertex.index());
178-
inherited_base::add_opened (vertex);
194+
inherited::add_opened (vertex);
179195
add_to_bucket (vertex,compute_bucket_id(vertex));
180196
verify_buckets ();
181197
}

src/xrAICore/Navigation/data_storage_double_linked_list.h

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/xrAICore/Navigation/data_storage_double_linked_list_inline.h

Lines changed: 0 additions & 166 deletions
This file was deleted.

src/xrAICore/xrAICore.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,6 @@
268268
<ClInclude Include="Navigation\data_storage_bucket_list.h" />
269269
<ClInclude Include="Navigation\data_storage_bucket_list_inline.h" />
270270
<ClInclude Include="Navigation\data_storage_constructor.h" />
271-
<ClInclude Include="Navigation\data_storage_double_linked_list.h" />
272-
<ClInclude Include="Navigation\data_storage_double_linked_list_inline.h" />
273271
<ClInclude Include="Navigation\dijkstra.h" />
274272
<ClInclude Include="Navigation\dijkstra_inline.h" />
275273
<ClInclude Include="Navigation\edge_path.h" />

src/xrAICore/xrAICore.vcxproj.filters

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,6 @@
219219
<ClInclude Include="Navigation\data_storage_bucket_list_inline.h">
220220
<Filter>AI\Navigation\Pathfinding\DataStorages\PriorityQueues</Filter>
221221
</ClInclude>
222-
<ClInclude Include="Navigation\data_storage_double_linked_list.h">
223-
<Filter>AI\Navigation\Pathfinding\DataStorages\PriorityQueues</Filter>
224-
</ClInclude>
225-
<ClInclude Include="Navigation\data_storage_double_linked_list_inline.h">
226-
<Filter>AI\Navigation\Pathfinding\DataStorages\PriorityQueues</Filter>
227-
</ClInclude>
228222
<ClInclude Include="Navigation\vertex_allocator_fixed.h">
229223
<Filter>AI\Navigation\Pathfinding\DataStorages\VertexAllocators</Filter>
230224
</ClInclude>

0 commit comments

Comments
 (0)