gwnavruntime/path/patheventlist.h Source File

patheventlist.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 #pragma once
9 
14 
15 
16 namespace Kaim
17 {
18 
21 {
28 
32 
36 };
37 
40 {
46 };
47 
51 {
54 };
55 
56 
59 class PathEvent
60 {
61  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Path)
62 public:
63  // ------------------------------ Functions -----------------------------
64 
65  PathEvent()
66  : m_eventType(PathEventType_Undefined)
67  , m_eventStatusInList(PathEventStatus_Undefined)
68  , m_checkPointStatus(CheckPointStatus_EventIsNotACheckPoint)
69  , m_userSpecific(0)
70  {}
71 
72  void SetCheckPointStatus(CheckPointStatus checkPointStatus);
73  void SetCheckPointWithDirection(Vec2f direction);
74  bool IsACheckPoint() const;
75  bool IsACheckPointWithDirection() const;
76  const Vec2f& GetCheckPointDirection() const;
77 
78  bool IsOnUpperBound() const;
79  bool IsOnLowerBound() const;
80 
81  bool IsAtLastNodeOfPath() const;
82  bool IsAtLastNodeOfAChannel() const;
83  Path* GetPath() const;
84 
85 public: // internal
86  // ---------------------------------- Public Data Members ----------------------------------
87 
88  PositionOnPath m_positionOnPath;
89  PathEventType m_eventType;
90  PathEventStatusInList m_eventStatusInList;
91  CheckPointStatus m_checkPointStatus;
92  Vec2f m_checkPointDirection;
93 
94  KyUInt32 m_userSpecific;
95 };
96 
97 
100 {
101  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Path)
102 public:
103  // ------------------------------ Functions -----------------------------
104 
105  PathEventInterval() {}
106 
107 
108  // ---------------------------------- Public Data Members ----------------------------------
109 
110  PathEvent m_endingEventOnPath;
111  NavTagPtr m_navTagOnInterval;
112 };
113 
114 
118 {
119  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Bot)
121 
122 public:
123  // ------------------------------ Functions -----------------------------
124 
125  PathEventList();
126  ~PathEventList();
127 
128  void Clear();
129 
130  KyUInt32 GetPathEventCount() const;
131  KyUInt32 GetPathEventIntervalCount() const;
132 
133  PathEvent& GetPathEvent(KyUInt32 eventIdx);
134  PathEvent& GetFirstPathEvent();
135  PathEvent& GetLastPathEvent();
136 
137  const PathEvent& GetPathEvent(KyUInt32 eventIdx) const;
138  const PathEvent& GetFirstPathEvent() const;
139  const PathEvent& GetLastPathEvent() const;
140 
144 
148 
151  const NavTag* GetNavTagOnIntervalBeforeEvent(KyUInt32 eventIdx) const;
152 
155  const NavTag* GetNavTagOnIntervalAfterEvent(KyUInt32 eventIdx) const;
156 
157  KyUInt32 GetStartPathEventIdxOfInterval(KyUInt32 intervalIdx) const;
158  KyUInt32 GetEndPathEventIdxOfInterval(KyUInt32 intervalIdx) const;
159 
160  const PathEvent& GetStartPathEventOfInterval(KyUInt32 intervalIdx) const;
161  const PathEvent& GetEndPathEventOfInterval(KyUInt32 intervalIdx) const;
162 
163  const NavTag* GetNavTagOfEventInterval(KyUInt32 intervalIdx) const;
164 
165 
166 public: // internal
167 
168  // the first interval is a dummy one used to store the first event.
169  // all the other PathEventInterval store the PathEvent at the end of the interval +
170  // a NavTagPtr from which the NavTag along the interval can be retrieved
171  KyArray<PathEventInterval, MemStat_Bot> m_pathEventIntervalArray;
172 };
173 
174 KY_INLINE void PathEvent::SetCheckPointStatus(CheckPointStatus checkPointStatus) { m_checkPointStatus = checkPointStatus; m_checkPointDirection = Vec2f::Zero(); }
175 KY_INLINE void PathEvent::SetCheckPointWithDirection(Vec2f direction) { m_checkPointStatus = CheckPointStatus_EventIsACheckPoint; m_checkPointDirection = direction; }
176 KY_INLINE bool PathEvent::IsACheckPoint() const { return m_checkPointStatus == CheckPointStatus_EventIsACheckPoint; }
177 KY_INLINE bool PathEvent::IsACheckPointWithDirection() const { return IsACheckPoint() == true && m_checkPointDirection != Vec2f::Zero(); }
178 KY_INLINE const Vec2f& PathEvent::GetCheckPointDirection() const { return m_checkPointDirection; }
179 
180 KY_INLINE bool PathEvent::IsOnUpperBound() const { return m_eventStatusInList == PathEventStatus_UpperBound || m_eventStatusInList == PathEventStatus_TemporaryUpperBound; }
181 KY_INLINE bool PathEvent::IsOnLowerBound() const { return m_eventStatusInList == PathEventStatus_LowerBound; }
182 
183 KY_INLINE bool PathEvent::IsAtLastNodeOfPath() const { return m_positionOnPath.IsAtLastNodeOfPath(); }
184 KY_INLINE bool PathEvent::IsAtLastNodeOfAChannel() const { return m_positionOnPath.IsAtLastNodeOfAChannel(); }
185 
186 KY_INLINE Path* PathEvent::GetPath() const { return m_positionOnPath.GetPath(); }
187 
188 KY_INLINE PathEventList::PathEventList() {}
189 KY_INLINE PathEventList::~PathEventList() { Clear(); }
190 
191 KY_INLINE void PathEventList::Clear() { m_pathEventIntervalArray.Clear(); }
192 
193 KY_INLINE KyUInt32 PathEventList::GetPathEventCount() const { return m_pathEventIntervalArray.GetCount(); }
194 
195 KY_INLINE KyUInt32 PathEventList::GetPathEventIntervalCount() const
196 {
197  if (m_pathEventIntervalArray.GetCount() != 0)
198  return m_pathEventIntervalArray.GetCount() - 1;
199 
200  return 0;
201 }
202 
204 {
205  KY_LOG_ERROR_IF(eventIdx >= GetPathEventCount(), ("Input index is not a valid event index"));
206  KY_LOG_ERROR_IF(eventIdx == 0, ("You cannot retrieve the index of the interval before the first event. It will return unused index"));
207  return eventIdx - 1;
208 }
209 
211 {
212  KY_LOG_ERROR_IF(eventIdx >= GetPathEventCount(), ("Input index is not a valid event index"));
213  KY_LOG_ERROR_IF(eventIdx == GetPathEventCount() - 1, ("You cannot retrieve the index of the interval after the last event. It will return unused index"));
214  return eventIdx;
215 }
216 
217 KY_INLINE const NavTag* PathEventList::GetNavTagOnIntervalBeforeEvent(KyUInt32 eventIdx) const
218 {
219  return GetNavTagOfEventInterval(GetIntervalIdxBeforeEvent(eventIdx));
220 }
221 KY_INLINE const NavTag* PathEventList::GetNavTagOnIntervalAfterEvent(KyUInt32 eventIdx) const
222 {
223  return GetNavTagOfEventInterval(GetIntervalIdxAfterEvent(eventIdx));
224 }
225 
226 KY_INLINE const NavTag* PathEventList::GetNavTagOfEventInterval(KyUInt32 intervalIdx) const
227 {
228  KY_LOG_ERROR_IF(intervalIdx >= GetPathEventIntervalCount(), ("Input index is not a valid interval index"));
229  return m_pathEventIntervalArray[intervalIdx + 1].m_navTagOnInterval.GetNavTag();
230 }
231 
232 KY_INLINE KyUInt32 PathEventList::GetStartPathEventIdxOfInterval(KyUInt32 intervalIdx) const
233 {
234  KY_LOG_ERROR_IF(intervalIdx >= GetPathEventIntervalCount(), ("Input index is not a valid interval index"));
235  return intervalIdx;
236 }
237 KY_INLINE KyUInt32 PathEventList::GetEndPathEventIdxOfInterval(KyUInt32 intervalIdx) const
238 {
239  KY_LOG_ERROR_IF(intervalIdx >= GetPathEventIntervalCount(), ("Input index is not a valid interval index"));
240  return intervalIdx + 1;
241 }
242 
243 KY_INLINE const PathEvent& PathEventList::GetStartPathEventOfInterval(KyUInt32 intervalIdx) const
244 {
245  KY_DEBUG_ASSERTN(intervalIdx < GetPathEventIntervalCount(), ("Input index is not a valid interval index"));
246  return m_pathEventIntervalArray[intervalIdx].m_endingEventOnPath;
247 }
248 KY_INLINE const PathEvent& PathEventList::GetEndPathEventOfInterval(KyUInt32 intervalIdx) const
249 {
250  KY_DEBUG_ASSERTN(intervalIdx < GetPathEventIntervalCount(), ("Input index is not a valid interval index"));
251  return m_pathEventIntervalArray[intervalIdx + 1].m_endingEventOnPath;
252 }
253 
254 KY_INLINE PathEvent& PathEventList::GetPathEvent(KyUInt32 eventIdx)
255 {
256  KY_DEBUG_ASSERTN(eventIdx < GetPathEventCount(), ("Input index is not a valid event index"));
257  return m_pathEventIntervalArray[eventIdx].m_endingEventOnPath;
258 }
259 
260 KY_INLINE PathEvent& PathEventList::GetFirstPathEvent() { return GetPathEvent(0); }
261 KY_INLINE PathEvent& PathEventList::GetLastPathEvent() { return GetPathEvent(GetPathEventCount() - 1); }
262 
263 KY_INLINE const PathEvent& PathEventList::GetPathEvent(KyUInt32 eventIdx) const
264 {
265  KY_DEBUG_ASSERTN(eventIdx < GetPathEventCount(), ("Input index is not a valid event index"));
266  return m_pathEventIntervalArray[eventIdx].m_endingEventOnPath;
267 }
268 
269 KY_INLINE const PathEvent& PathEventList::GetFirstPathEvent() const { return GetPathEvent(0); }
270 KY_INLINE const PathEvent& PathEventList::GetLastPathEvent() const { return GetPathEvent(GetPathEventCount() - 1); }
271 
272 
273 } // namespace Kaim
274 
event is not a user checkpoint
Definition: patheventlist.h:52
This class aggregates all necessary information about a position on a Path.
Definition: positiononpath.h:29
PathEventList aggregates all PathEvents and PathEventIntervals in a PathValidityInterval.
Definition: patheventlist.h:117
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
PathEvent is the PathValidityInterval upper bound.
Definition: patheventlist.h:44
PathValidityInterval bound specific: bound reached start or end of the path or the max distance of va...
Definition: patheventlist.h:31
void SetCheckPointStatus(CheckPointStatus checkPointStatus)
Allows to change the user checkpoint status of the PathEvent.
Definition: patheventlist.h:174
PathEvent is the PathValidityInterval temporary upper bound.
Definition: patheventlist.h:45
bool IsACheckPoint() const
returns true if it is a check point with or without direction
Definition: patheventlist.h:176
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:162
const NavTag * GetNavTagOnIntervalAfterEvent(KyUInt32 eventIdx) const
Returns a pointer to the NavTag lying under the interval starting at the event of index eventIdx...
Definition: patheventlist.h:221
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
CheckPointStatus
Defines whether the PathEvent is a check point or not.
Definition: patheventlist.h:50
Each instance of this class uniquely identifies a single NavFloor.
Definition: navtagptr.h:21
KyUInt32 GetIntervalIdxAfterEvent(KyUInt32 eventIdx) const
Return the index of interval starting at the event of index eventIdx.
Definition: patheventlist.h:210
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
The PathEvent is at a transition between the NavMesh and a PathEdge going from the NavMesh to outside...
Definition: patheventlist.h:26
The PathEvent is at a transition between different NavTags.
Definition: patheventlist.h:24
const Vec2f & GetCheckPointDirection() const
relevant only if IsACheckPointWithDirection() returns true
Definition: patheventlist.h:178
PathEvent is the PathValidityInterval lower bound.
Definition: patheventlist.h:43
The PathEvent is at a transition between the NavMesh and a PathEdge going from outside to the NavMesh...
Definition: patheventlist.h:25
2d vector using KyFloat32.
Definition: vec2f.h:18
KyUInt32 GetIntervalIdxBeforeEvent(KyUInt32 eventIdx) const
Return the index of interval ending at the event of index eventIdx.
Definition: patheventlist.h:203
A PathEvent is a particular PositionOnPath which feature is specified by a PathEventType.
Definition: patheventlist.h:59
This class represents an interval between two PathEvents within a PathEventList.
Definition: patheventlist.h:99
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
PathEventStatusInList
Defines the PathEvent status relative to its place in the PathEventList.
Definition: patheventlist.h:39
void SetCheckPointWithDirection(Vec2f direction)
Set CheckPointStatus_EventIsACheckPoint and assigned it a direction (Currently only used with Traject...
Definition: patheventlist.h:175
const NavTag * GetNavTagOnIntervalBeforeEvent(KyUInt32 eventIdx) const
Returns a pointer to the NavTag lying under interval ending at the event of index eventIdx...
Definition: patheventlist.h:217
The PathEvent is not yet defined.
Definition: patheventlist.h:22
static Vec2f Zero()
Returns {0.0f, 0.0f}.
Definition: vec2f.h:93
PathEvent neither lower bound nor upper bound.
Definition: patheventlist.h:42
event is a user checkpoint with no direction specified
Definition: patheventlist.h:53
The PathEvent is outside the NavMesh.
Definition: patheventlist.h:27
bool IsACheckPointWithDirection() const
returns true only if is a checkpoint with direction, i.e. it returns false if it is a checkpoint but ...
Definition: patheventlist.h:177
PathValidityInterval bound specific: bound hit a border or a non-traversable navTag boundary during v...
Definition: patheventlist.h:35
The PathEvent is on a NavGraph vertex.
Definition: patheventlist.h:23
PathEvent is not yet defined.
Definition: patheventlist.h:41
The class representing a path.
Definition: path.h:62
PathEventType
Defines the different kinds of PathEvent.
Definition: patheventlist.h:20