gwnavruntime/path/patheventlist.h Source File

patheventlist.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 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 // primary contact: LAPA - secondary contact: MUBI
9 
10 #ifndef Navigation_PathEventList_H
11 #define Navigation_PathEventList_H
12 
17 
18 
19 namespace Kaim
20 {
21 
24 {
31 
35 
39 };
40 
43 {
49 };
50 
54 {
57 };
58 
59 
62 class PathEvent
63 {
64  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Path)
65 public:
66  // ---------------------------------- Public Member Functions ----------------------------------
67 
68  PathEvent()
69  : m_eventType(PathEventType_Undefined)
70  , m_eventStatusInList(PathEventStatus_Undefined)
71  , m_checkPointStatus(CheckPointStatus_EventIsNotACheckPoint)
72  , m_userSpecific(0)
73  {}
74 
75  void SetCheckPointStatus(CheckPointStatus checkPointStatus);
76  void SetCheckPointWithDirection(Vec2f direction);
77  bool IsACheckPoint() const;
78  bool IsACheckPointWithDirection() const;
79  const Vec2f& GetCheckPointDirection() const;
80 
81  bool IsOnUpperBound() const;
82  bool IsOnLowerBound() const;
83 
84  bool IsAtLastNodeOfPath() const;
85  bool IsAtLastNodeOfAChannel() const;
86  Path* GetPath() const;
87 
88 public: // internal
89  // ---------------------------------- Public Data Members ----------------------------------
90 
91  PositionOnPath m_positionOnPath;
92  PathEventType m_eventType;
93  PathEventStatusInList m_eventStatusInList;
94  CheckPointStatus m_checkPointStatus;
95  Vec2f m_checkPointDirection;
96 
97  KyUInt32 m_userSpecific;
98 };
99 
100 
102 class PathEventInterval
103 {
104  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Path)
105 public:
106  // ---------------------------------- Public Member Functions ----------------------------------
107 
108  PathEventInterval() {}
109 
110 
111  // ---------------------------------- Public Data Members ----------------------------------
112 
113  PathEvent m_endingEventOnPath;
114  NavTagPtr m_navTagOnInterval;
115 };
116 
117 
120 class PathEventList
121 {
122  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Bot)
124 
125 public:
126  // ---------------------------------- Public Member Functions ----------------------------------
127 
128  PathEventList();
129  ~PathEventList();
130 
131  void Clear();
132 
133  KyUInt32 GetPathEventCount() const;
134  KyUInt32 GetPathEventIntervalCount() const;
135 
136  PathEvent& GetPathEvent(KyUInt32 eventIdx);
137  PathEvent& GetFirstPathEvent();
138  PathEvent& GetLastPathEvent();
139 
140  const PathEvent& GetPathEvent(KyUInt32 eventIdx) const;
141  const PathEvent& GetFirstPathEvent() const;
142  const PathEvent& GetLastPathEvent() const;
143 
147 
151 
154  const NavTag* GetNavTagOnIntervalBeforeEvent(KyUInt32 eventIdx) const;
155 
158  const NavTag* GetNavTagOnIntervalAfterEvent(KyUInt32 eventIdx) const;
159 
160  KyUInt32 GetStartPathEventIdxOfInterval(KyUInt32 intervalIdx) const;
161  KyUInt32 GetEndPathEventIdxOfInterval(KyUInt32 intervalIdx) const;
162 
163  const PathEvent& GetStartPathEventOfInterval(KyUInt32 intervalIdx) const;
164  const PathEvent& GetEndPathEventOfInterval(KyUInt32 intervalIdx) const;
165 
166  const NavTag* GetNavTagOfEventInterval(KyUInt32 intervalIdx) const;
167 
168 
169 public: // internal
170 
171  // the first interval is a dummy one used to store the first event.
172  // all the other PathEventInterval store the PathEvent at the end of the interval +
173  // a NavTagPtr from which the NavTag along the interval can be retrieved
174  KyArray<PathEventInterval, MemStat_Bot> m_pathEventIntervalArray;
175 };
176 
177 KY_INLINE void PathEvent::SetCheckPointStatus(CheckPointStatus checkPointStatus) { m_checkPointStatus = checkPointStatus; m_checkPointDirection = Vec2f::Zero(); }
178 KY_INLINE void PathEvent::SetCheckPointWithDirection(Vec2f direction) { m_checkPointStatus = CheckPointStatus_EventIsACheckPoint; m_checkPointDirection = direction; }
179 KY_INLINE bool PathEvent::IsACheckPoint() const { return m_checkPointStatus == CheckPointStatus_EventIsACheckPoint; }
180 KY_INLINE bool PathEvent::IsACheckPointWithDirection() const { return IsACheckPoint() == true && m_checkPointDirection != Vec2f::Zero(); }
181 KY_INLINE const Vec2f& PathEvent::GetCheckPointDirection() const { return m_checkPointDirection; }
182 
183 KY_INLINE bool PathEvent::IsOnUpperBound() const { return m_eventStatusInList == PathEventStatus_UpperBound || m_eventStatusInList == PathEventStatus_TemporaryUpperBound; }
184 KY_INLINE bool PathEvent::IsOnLowerBound() const { return m_eventStatusInList == PathEventStatus_LowerBound; }
185 
186 KY_INLINE bool PathEvent::IsAtLastNodeOfPath() const { return m_positionOnPath.IsAtLastNodeOfPath(); }
187 KY_INLINE bool PathEvent::IsAtLastNodeOfAChannel() const { return m_positionOnPath.IsAtLastNodeOfAChannel(); }
188 
189 KY_INLINE Path* PathEvent::GetPath() const { return m_positionOnPath.GetPath(); }
190 
191 KY_INLINE PathEventList::PathEventList() {}
192 KY_INLINE PathEventList::~PathEventList() { Clear(); }
193 
194 KY_INLINE void PathEventList::Clear() { m_pathEventIntervalArray.Clear(); }
195 
196 KY_INLINE KyUInt32 PathEventList::GetPathEventCount() const { return m_pathEventIntervalArray.GetCount(); }
197 
198 KY_INLINE KyUInt32 PathEventList::GetPathEventIntervalCount() const
199 {
200  if (m_pathEventIntervalArray.GetCount() != 0)
201  return m_pathEventIntervalArray.GetCount() - 1;
202 
203  return 0;
204 }
205 
207 {
208  KY_LOG_ERROR_IF(eventIdx >= GetPathEventCount(), ("Input index is not a valid event index"));
209  KY_LOG_ERROR_IF(eventIdx == 0, ("You cannot retrieve the index of the interval before the first event. It will return unused index"));
210  return eventIdx - 1;
211 }
212 
214 {
215  KY_LOG_ERROR_IF(eventIdx >= GetPathEventCount(), ("Input index is not a valid event index"));
216  KY_LOG_ERROR_IF(eventIdx == GetPathEventCount() - 1, ("You cannot retrieve the index of the interval after the last event. It will return unused index"));
217  return eventIdx;
218 }
219 
220 KY_INLINE const NavTag* PathEventList::GetNavTagOnIntervalBeforeEvent(KyUInt32 eventIdx) const
221 {
222  return GetNavTagOfEventInterval(GetIntervalIdxBeforeEvent(eventIdx));
223 }
224 KY_INLINE const NavTag* PathEventList::GetNavTagOnIntervalAfterEvent(KyUInt32 eventIdx) const
225 {
226  return GetNavTagOfEventInterval(GetIntervalIdxAfterEvent(eventIdx));
227 }
228 
229 KY_INLINE const NavTag* PathEventList::GetNavTagOfEventInterval(KyUInt32 intervalIdx) const
230 {
231  KY_LOG_ERROR_IF(intervalIdx >= GetPathEventIntervalCount(), ("Input index is not a valid interval index"));
232  return m_pathEventIntervalArray[intervalIdx + 1].m_navTagOnInterval.GetNavTag();
233 }
234 
235 KY_INLINE KyUInt32 PathEventList::GetStartPathEventIdxOfInterval(KyUInt32 intervalIdx) const
236 {
237  KY_LOG_ERROR_IF(intervalIdx >= GetPathEventIntervalCount(), ("Input index is not a valid interval index"));
238  return intervalIdx;
239 }
240 KY_INLINE KyUInt32 PathEventList::GetEndPathEventIdxOfInterval(KyUInt32 intervalIdx) const
241 {
242  KY_LOG_ERROR_IF(intervalIdx >= GetPathEventIntervalCount(), ("Input index is not a valid interval index"));
243  return intervalIdx + 1;
244 }
245 
246 KY_INLINE const PathEvent& PathEventList::GetStartPathEventOfInterval(KyUInt32 intervalIdx) const
247 {
248  KY_DEBUG_ASSERTN(intervalIdx < GetPathEventIntervalCount(), ("Input index is not a valid interval index"));
249  return m_pathEventIntervalArray[intervalIdx].m_endingEventOnPath;
250 }
251 KY_INLINE const PathEvent& PathEventList::GetEndPathEventOfInterval(KyUInt32 intervalIdx) const
252 {
253  KY_DEBUG_ASSERTN(intervalIdx < GetPathEventIntervalCount(), ("Input index is not a valid interval index"));
254  return m_pathEventIntervalArray[intervalIdx + 1].m_endingEventOnPath;
255 }
256 
257 KY_INLINE PathEvent& PathEventList::GetPathEvent(KyUInt32 eventIdx)
258 {
259  KY_DEBUG_ASSERTN(eventIdx < GetPathEventCount(), ("Input index is not a valid event index"));
260  return m_pathEventIntervalArray[eventIdx].m_endingEventOnPath;
261 }
262 
263 KY_INLINE PathEvent& PathEventList::GetFirstPathEvent() { return GetPathEvent(0); }
264 KY_INLINE PathEvent& PathEventList::GetLastPathEvent() { return GetPathEvent(GetPathEventCount() - 1); }
265 
266 KY_INLINE const PathEvent& PathEventList::GetPathEvent(KyUInt32 eventIdx) const
267 {
268  KY_DEBUG_ASSERTN(eventIdx < GetPathEventCount(), ("Input index is not a valid event index"));
269  return m_pathEventIntervalArray[eventIdx].m_endingEventOnPath;
270 }
271 
272 KY_INLINE const PathEvent& PathEventList::GetFirstPathEvent() const { return GetPathEvent(0); }
273 KY_INLINE const PathEvent& PathEventList::GetLastPathEvent() const { return GetPathEvent(GetPathEventCount() - 1); }
274 
275 
276 } // namespace Kaim
277 
278 #endif // Navigation_PathEventList_H
event is not a user checkpoint
Definition: patheventlist.h:55
This class aggregates all necessary information about a position on a Path, namely: ...
Definition: positiononpath.h:33
PathEventList aggregates all PathEvents and PathEventIntervals in a PathValidityInterval.
Definition: patheventlist.h:141
PathEvent is the PathValidityInterval upper bound.
Definition: patheventlist.h:47
PathValidityInterval bound specific: bound reached start or end of the path or the max distance of va...
Definition: patheventlist.h:34
void SetCheckPointStatus(CheckPointStatus checkPointStatus)
Allows to change the user checkpoint status of the PathEvent.
Definition: patheventlist.h:206
PathEvent is the PathValidityInterval temporary upper bound.
Definition: patheventlist.h:48
bool IsACheckPoint() const
returns true if it is a check point with or without direction
Definition: patheventlist.h:208
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:118
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:253
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
CheckPointStatus
Defines whether the PathEvent is a check point or not.
Definition: patheventlist.h:53
Each instance of this class uniquely identifies a single NavFloor.
Definition: navtagptr.h:26
KyUInt32 GetIntervalIdxAfterEvent(KyUInt32 eventIdx) const
Return the index of interval starting at the event of index eventIdx.
Definition: patheventlist.h:242
The PathEvent is at a transition between the NavMesh and a PathEdge going from the NavMesh to outside...
Definition: patheventlist.h:29
The PathEvent is at a transition between different NavTags.
Definition: patheventlist.h:27
const Vec2f & GetCheckPointDirection() const
relevant only if IsACheckPointWithDirection() returns true
Definition: patheventlist.h:210
PathEvent is the PathValidityInterval lower bound.
Definition: patheventlist.h:46
The PathEvent is at a transition between the NavMesh and a PathEdge going from outside to the NavMesh...
Definition: patheventlist.h:28
This class defines a two-dimensional vector whose coordinates are stored using floating-point numbers...
Definition: vec2f.h:24
KyUInt32 GetIntervalIdxBeforeEvent(KyUInt32 eventIdx) const
Return the index of interval ending at the event of index eventIdx.
Definition: patheventlist.h:235
A PathEvent is a particular PositionOnPath which feature is specified by a PathEventType.
Definition: patheventlist.h:62
This class represents an interval between two PathEvents within a PathEventList.
Definition: patheventlist.h:114
Definition: gamekitcrowddispersion.h:20
PathEventStatusInList
Defines the PathEvent status relative to its place in the PathEventList.
Definition: patheventlist.h:42
void SetCheckPointWithDirection(Vec2f direction)
Set CheckPointStatus_EventIsACheckPoint and assigned it a direction (Currently only used with Traject...
Definition: patheventlist.h:207
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:249
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
The PathEvent is not yet defined.
Definition: patheventlist.h:25
static Vec2f Zero()
Returns a vector of zero size: (0,0).
Definition: vec2f.h:154
PathEvent neither lower bound nor upper bound.
Definition: patheventlist.h:45
event is a user checkpoint with no direction specified
Definition: patheventlist.h:56
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
The PathEvent is outside the NavMesh.
Definition: patheventlist.h:30
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:209
PathValidityInterval bound specific: bound hit a border or a non-traversable navTag boundary during v...
Definition: patheventlist.h:38
The PathEvent is on a NavGraph vertex.
Definition: patheventlist.h:26
PathEvent is not yet defined.
Definition: patheventlist.h:44
The class representing a path.
Definition: path.h:42
PathEventType
Defines the different kinds of PathEvent.
Definition: patheventlist.h:23