-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathtypes.h
More file actions
143 lines (122 loc) Β· 2.4 KB
/
Copy pathtypes.h
File metadata and controls
143 lines (122 loc) Β· 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Copyright 2024-2025 the openage authors. See copying.md for legal info.
#pragma once
#include <cstddef>
#include <cstdint>
#include <memory>
#include <utility>
#include "time/time.h"
namespace openage::path {
/**
* Path result type.
*/
enum class PathResult {
/// Path was found.
FOUND,
/// Path was not found.
NOT_FOUND,
/// Target is not on grid.
OUT_OF_BOUNDS,
};
/**
* Movement cost in the cost field.
*
* TODO: Cost stamps
*
* 0: uninitialized
* 1-254: normal cost
* 255: impassable
*/
using cost_t = uint8_t;
/**
* Integrated cost in the integration field.
*/
using integrated_cost_t = uint16_t;
/**
* Integrated field cell flags.
*/
using integrated_flags_t = uint8_t;
/**
* Integration field cell value.
*/
struct integrated_t {
/**
* Total integrated cost.
*/
integrated_cost_t cost;
/**
* Flags.
*
* Bit 0-3: Shared flags with the flow field.
* - 0: Unused.
* - 1: Target flag.
* - 2: Line of sight flag.
* - 3: Unused.
* Bit 4-7: Integration field specific flags.
* - 4: Unused.
* - 5: Wave front blocked flag.
* - 6: LOS found flag.
* - 7: Unused.
*/
integrated_flags_t flags;
};
/**
* Flow field direction types.
*
* Encoded into the flow_t values.
*/
enum class flow_dir_t : uint8_t {
NORTH = 0x00,
NORTH_EAST = 0x01,
EAST = 0x02,
SOUTH_EAST = 0x03,
SOUTH = 0x04,
SOUTH_WEST = 0x05,
WEST = 0x06,
NORTH_WEST = 0x07,
};
/**
* Flow field cell value.
*
* Bit 0: Unused.
* Bit 1: Target flag.
* Bit 2: Line of sight flag.
* Bit 3: Pathable flag.
* Bits 4-7: flow direction.
*/
using flow_t = uint8_t;
/**
* Grid identifier.
*/
using grid_id_t = size_t;
/**
* Sector identifier (unique per grid).
*/
using sector_id_t = size_t;
/**
* Portal identifier (unique per grid).
*/
using portal_id_t = size_t;
class FlowField;
class IntegrationField;
/**
* Cache key for accessing the field cache using a portal id and a sector id.
*/
using cache_key_t = std::pair<portal_id_t, sector_id_t>;
/**
* Returnable field cache entry pair containing an integration field and a flow field.
*/
using field_cache_t = std::pair<std::shared_ptr<IntegrationField>, std::shared_ptr<FlowField>>;
/**
* Cost stamp for a given cost field cell.
*/
struct cost_stamp_t {
/**
* Original cost of the stamped cell.
*/
cost_t original_cost;
/**
* Time the cost field cell was stamped.
*/
time::time_t stamp_time;
};
} // namespace openage::path