gwnavruntime/path/positiononlivepath.h Source File

positiononlivepath.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 
15 
16 
17 namespace Kaim
18 {
19 
20 class Bot;
21 class IMovePositionOnLivePathPredicate;
22 
25 {
29 };
30 
31 
44 {
45  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Path)
46 
47 public:
48  // ---------------------------------- Main API Functions ----------------------------------
49 
51  void BindToPathEventList(PathEventList* pathEventList);
52  PathEventList* GetPathEventList() const { return m_pathEventList; }
53 
54  void Clear();
55  void ClearEventListLocation();
56 
57 
58  // ---------------------------------- Comparison Operators ----------------------------------
59 
60  bool operator==(const PositionOnLivePath& positionOnLivePath) const;
61  bool operator!=(const PositionOnLivePath& positionOnLivePath) const;
62 
63 
64  // ---------------------------------- Raw Path Related Functions ----------------------------------
65 
66  Path* GetPath() { return m_positionOnPath.GetPath(); }
67  const Path* GetPath() const { return m_positionOnPath.GetPath(); }
68  const Vec3f& GetPosition() const { return m_positionOnPath.GetPosition(); }
69  const PositionOnPath& GetPositionOnPath() const { return m_positionOnPath; }
70  PositionOnPathStatus GetPositionOnPathStatus() const { return m_positionOnPath.GetPositionOnPathStatus(); }
71  PathEdgeType GetPathEdgeType() const { return m_positionOnPath.GetPathEdgeType(); }
72  bool IsAtFirstNodeOfPath() const { return m_positionOnPath.IsAtFirstNodeOfPath(); }
73  bool IsAtLastNodeOfPath() const { return m_positionOnPath.IsAtLastNodeOfPath(); }
74  bool IsAtFirstEdgeOfPath() const { return m_positionOnPath.IsAtFirstEdgeOfPath(); }
75  bool IsAtLastEdgeOfPath() const { return m_positionOnPath.IsAtLastEdgeOfPath(); }
76  KyUInt32 GetPathEdgeIndex() const { return m_positionOnPath.GetPathEdgeIndex(); }
77  KyUInt32 GetEdgeIdxToMoveOnForward() const { return m_positionOnPath.GetEdgeIdxToMoveOnForward(); }
78  PathEdgeType GetEdgeTypeToMoveOnForward() const { return m_positionOnPath.GetEdgeTypeToMoveOnForward(); }
79  PathEdgeType GetEdgeTypeToMoveOnBackward() const { return m_positionOnPath.GetEdgeTypeToMoveOnBackward(); }
80  KyUInt32 GetEdgeIdxToMoveOnBackward() const { return m_positionOnPath.GetEdgeIdxToMoveOnBackward(); }
81  bool DoesPrecede(const PositionOnLivePath& other) const { return m_positionOnPath.DoesPrecede(other.m_positionOnPath); }
82  bool IsStrictlyBefore(const PositionOnLivePath& other) const { return m_positionOnPath.IsStrictlyBefore(other.m_positionOnPath); }
83 
84  // ---------------------------------- PositionOnLivePath initialization on Path----------------------------------
88 
89  void InitOnPathFirstNode(Path* path);
90  void InitOnPathLastNode(Path* path);
91  void InitOnPathNode(Path* path, KyUInt32 pathNodeIdx);
92  void InitOnPathEdge(Path* path, const Vec3f& positionOnEdge, KyUInt32 pathEdgeIdx);
93  void InitOnPositionOnPath(const PositionOnPath& positionOnPath);
94 
97 
98  // ---------------------------------- PathEventList Related Functions ----------------------------------
99 
100  OnEventListStatus GetOnEventListStatus() const { return m_onEventListStatus; }
101 
102  PathEvent GetPathEvent(KyUInt32 pathEventIdx) const;
103  PathEvent GetCurrentPathEvent() const; // return copy of current PathEvent _if and only if_ on a PathEvent!
104 
108  KyUInt32 GetOnEventListIndex() const { return m_currentOnEventListIdx; }
109 
116 
123 
124  bool IsAtLowerBoundOfLivePath() const;
125  bool IsAtUpperBoundOfLivePath() const;
126 
128  bool IsAtACheckPoint() const;
129 
136 
143  const NavTag* GetCurrentOrNextNavTag() const;
144 
151  const NavTag* GetCurrentOrPreviousNavTag() const;
152 
153 
154  // ---------------------------------- Move Functions ----------------------------------
155 
160  void MoveForward(KyFloat32 distanceMove);
161 
166  void MoveBackward(KyFloat32 distanceMove);
167 
173  void MoveForward_StopAtPathNode(KyFloat32 distanceMove);
174 
180  void MoveBackward_StopAtPathNode(KyFloat32 distanceMove);
181 
186  void MoveForward_StopAtEvent(KyFloat32 distanceMove);
187 
192  void MoveBackward_StopAtEvent(KyFloat32 distanceMove);
193 
200 
207 
210 
213 
219  void MoveForward_StopAtCheckPoint(KyFloat32 distanceMove);
220 
225 
230 
233  void MoveToPathEvent(KyUInt32 pathEventIdx);
234 
239 
244 
249 
254 
259 
264 
269 
275 
279 
283 
287  void SetNewPositionOnPathForward(const PositionOnPath& newPositionOnPathForward);
288 
292  void SetNewPositionOnPathBackward(const PositionOnPath& newPositionOnPathBackward);
293 
294  // ---------------------------------- Move Functions with Cost ----------------------------------
295 
302  template<class TraverseLogic>
303  void MoveForwardAndGetCost_StopAtEventOrAtPathNode(void* traverseLogicUserData, KyFloat32 distanceMove, RayCanGoMarginMode rayCanGoMarginMode, KyFloat32& cost);
304 
305 
306  // ---------------------------------- Unsafe Version of Functions ----------------------------------
308 
309  // cf. GetNextPathEventIdx()
311  // cf. GetPrevPathEventIdx()
312  KyUInt32 GetPrevPathEventIdx_Unsafe() const;
313  // cf. MoveForwardToNextPathEvent()
314  void MoveForwardToNextPathEvent_Unsafe();
315  // cf. MoveBackwardToPrevPathEvent()
316  void MoveBackwardToPrevPathEvent_Unsafe();
317  // cf. MoveForwardToNextPathEventInterval()
318  void MoveForwardToNextPathEventInterval_Unsafe();
319 
320 public: // DEPRECATED
321  // ------------- Deprecated functions --------------
322  KY_DEPRECATED(const NavTag* GetUpcomingEventNavTag() const) { return GetCurrentOrNextNavTag(); }
323  KY_DEPRECATED(const NavTag* GetPreviousEventNavTag() const) { return GetCurrentOrPreviousNavTag(); }
324 
325 private:
326  bool IsEventListStatusValid() const;
327 
328  void FixLocationOnEventListAfterMovingForward();
329  void FixLocationOnEventListAfterMovingBackward();
330  void StopAtEventAfterMovingForward();
331  void StopAtEventAfterMovingBackward();
332  void StopAtCheckPointAfterMovingForward();
333 
334  template<class TraverseLogic>
335  void GetCostAfterStopAtEventOrAtPathNode(void* traverseLogicUserData, const Vec3f& posBeforeMove, const NavTag* navTag,
336  RayCanGoMarginMode rayCanGoMarginMode, KyFloat32& cost, const LogicWithNoCustomCost&);
337  template<class TraverseLogic>
338  void GetCostAfterStopAtEventOrAtPathNode(void* traverseLogicUserData, const Vec3f& posBeforeMove, const NavTag* navTag,
339  RayCanGoMarginMode rayCanGoMarginMode, KyFloat32& cost, const LogicWithCostPerNavTag&);
340  template<class TraverseLogic>
341  void GetCostAfterStopAtEventOrAtPathNode(void* traverseLogicUserData, const Vec3f& posBeforeMove, const NavTag* navTag,
342  RayCanGoMarginMode rayCanGoMarginMode, KyFloat32& cost, const LogicWithCostPerTriangle&);
343 
344 private:
345  PathEventList* m_pathEventList;
346  PositionOnPath m_positionOnPath;
347  OnEventListStatus m_onEventListStatus;
348  KyUInt32 m_currentOnEventListIdx; // index on the event or index of the interval. position is on ]EventIntervalStart, EventIntervalEnd]
349 };
350 
351 } // namespace Kaim
352 
354 
PathEdgeType GetEdgeTypeToMoveOnForward() const
return the type of the edge given by GetEdgeIdxToMoveOnForward()
Definition: positiononpath.h:70
void MoveForward_StopAtCheckPoint(KyFloat32 distanceMove)
This function moves forward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:370
OnEventListStatus
Enumerates the admissible values for PositionOnLivePath status accordingly to its position relatively...
Definition: positiononlivepath.h:24
void MoveBackwardToPrevPathNode()
This function moves backward the position up to the previous Path node.
Definition: positiononlivepath.inl:414
KyUInt32 GetPathEdgeIndex() const
This function has to be used carefully:
Definition: positiononpath.inl:10
KyUInt32 GetEdgeIdxToMoveOnForward() const
If this in on a Path node, it returns the index of the edge starting at this Path node...
Definition: positiononpath.inl:20
void MoveBackwardToPreviousEventWithPredicate(IMovePositionOnLivePathPredicate *predicate)
This function will move positionOnLivePath backward until the predicate returns false.
Definition: positiononlivepath.cpp:271
This class aggregates all necessary information about a position on a Path.
Definition: positiononpath.h:29
void MoveBackward_StopAtPathNode(KyFloat32 distanceMove)
This function moves backward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:458
PathEventList aggregates all PathEvents and PathEventIntervals in a PathValidityInterval.
Definition: patheventlist.h:117
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
void MoveToPathEvent(KyUInt32 pathEventIdx)
This function moves the position to the specified path event.
Definition: positiononlivepath.inl:285
void MoveForwardToNextPathNode()
This function moves forward the position up to the next Path node.
Definition: positiononlivepath.inl:403
PositionOnPathStatus
< enumerates="" the="" different="" status="" an="" objectpositiononpath="" can="" have="" on="" its="" path.="" />
Definition: positiononpath.h:17
bool IsAtACheckPoint() const
Indicates if the PositionOnLIvePath is at an event that is a check point.
Definition: positiononlivepath.inl:26
void MoveForwardToNextPathEdge()
This function moves forward the position up to the start of the next path edge.
Definition: positiononlivepath.inl:425
KyUInt32 GetEdgeIdxToMoveOnBackward() const
If this in on a Path node, it returns the index of the edge ending at this Path node, else it returns the index of the edge current instance lies on.
Definition: positiononpath.h:103
bool IsStrictlyBefore(const PositionOnPath &other) const
Returns true when this PositionOnPath strictly precede the other one; returns false if it as as the s...
Definition: positiononpath.cpp:236
void MoveToNextEventOrPathNode()
This function moves forward the position until an event or a pathNode is reached. ...
Definition: positiononlivepath.inl:348
The PositionOnLivePath is on a PathEvent.
Definition: positiononlivepath.h:27
PathEdgeType GetPathEdgeType() const
This function has to be used carefully, cf. GetPathEdgeIndex()
Definition: positiononpath.h:67
void MoveForwardToNextPathEvent()
This function moves forward the position up to the next path event.
Definition: positiononlivepath.inl:297
KyUInt32 GetNextPathEventIdx() const
This function has to be used carefully:
Definition: positiononlivepath.inl:262
The PositionOnLivePath is strictly on a PathEventInterval.
Definition: positiononlivepath.h:28
void MoveBackwardToPrevPathEdge()
This function moves forward the position up to the start of the next path edge.
Definition: positiononlivepath.inl:436
The PositionOnLivePath relative position in PathEventList is not yet defined.
Definition: positiononlivepath.h:26
void SetNewPositionOnPathBackward(const PositionOnPath &newPositionOnPathBackward)
Moves this PositionOnLivePath backward to the provided PositionOnPath and updates PathEventList relat...
Definition: positiononlivepath.inl:491
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
PathEdgeType GetEdgeTypeToMoveOnBackward() const
return the type of the edge given by GetEdgeIdxToMoveOnBackward()
Definition: positiononpath.h:73
void MoveForward_StopAtEventOrAtPathNode(KyFloat32 distanceMove)
This function moves forward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:326
void MoveForwardToNextPathEventInterval()
This function moves forward the position up to the next path event interval.
Definition: positiononlivepath.inl:316
void FindLocationOnEventListFromScratch()
This function computes the location on the PathEventList from the PositionOnPath. ...
Definition: positiononlivepath.cpp:285
void MoveBackwardToPrevCheckPoint()
This function moves backward the position up to the previous path event that is a check point...
Definition: positiononlivepath.cpp:244
KyUInt32 GetNextPathEventIdx_Unsafe() const
These functions are unsafe in regard to the pre-conditions mentioned in the functions of similar name...
Definition: positiononlivepath.cpp:50
Interface used to verify a PositionOnPath can be moved forward along the Path.
Definition: imovepositiononpathpredicate.h:17
RayCanGoMarginMode
Defines the different mode for the NavMesh border margin to be used in RayCanGo queries.
Definition: database.h:37
void MoveForwardAndGetCost_StopAtEventOrAtPathNode(void *traverseLogicUserData, KyFloat32 distanceMove, RayCanGoMarginMode rayCanGoMarginMode, KyFloat32 &cost)
This function moves forward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:179
A PathEvent is a particular PositionOnPath which feature is specified by a PathEventType.
Definition: patheventlist.h:59
#define KY_DEPRECATED(expr)
The compiler issues a warning when a deprecated function or typedef is used.
Definition: types.h:93
void MoveForward_StopAtEvent(KyFloat32 distanceMove)
This function moves forward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:78
void MoveForwardToNextPathEventWithPredicate(IMovePositionOnLivePathPredicate *predicate)
This function will move positionOnLivePath forward until the predicate returns false.
Definition: positiononlivepath.cpp:257
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
void MoveBackward_StopAtEvent(KyFloat32 distanceMove)
This function moves backward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:89
KyUInt32 GetOnEventListIndex() const
This function has to be used carefully:
Definition: positiononlivepath.h:108
void MoveBackward(KyFloat32 distanceMove)
This function moves backward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:392
const NavTag * GetCurrentOrNextNavTag() const
Returns a pointer to the navTag along the path after the position on path.
Definition: positiononlivepath.inl:129
KyUInt32 GetPrevPathEventIdx() const
This function has to be used carefully:
Definition: positiononlivepath.inl:273
void MoveBackwardToPrevPathEvent()
This function moves backward the position up to the previous path event.
Definition: positiononlivepath.inl:307
This class aggregates all necessary information to describe a position on a LivePath, namely:
Definition: positiononlivepath.h:43
KyFloat32 MoveForwardToClosestPositionOnPath(const Vec3f &position)
Move forward to the closest position on path from originalPosition.
Definition: positiononlivepath.inl:469
void MoveForward(KyFloat32 distanceMove)
This function moves forward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:381
void SetNewPositionOnPathForward(const PositionOnPath &newPositionOnPathForward)
Moves this PositionOnLivePath forward to the provided PositionOnPath and updates PathEventList relate...
Definition: positiononlivepath.inl:482
void MoveBackward_StopAtEventOrAtPathNode(KyFloat32 distanceMove)
This function moves backward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:337
bool DoesPrecede(const PositionOnPath &other) const
Returns true when this PositionOnPath precede or is at same position that the other one...
Definition: positiononpath.cpp:192
void MoveForwardToNextCheckPoint()
This function moves forward the position up to the next path event that is a check point...
Definition: positiononlivepath.cpp:231
void MoveToPrevEventOrPathNode()
This function moves backward the position until an event or a pathNode is reached.
Definition: positiononlivepath.inl:359
void MoveForward_StopAtPathNode(KyFloat32 distanceMove)
This function moves forward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:447
const PositionOnPath * GetUpcomingEventPositionOnPath() const
Returns a pointer to the PositionOnPath along the path after positionOnLivePath.
Definition: positiononlivepath.inl:101
The class representing a path.
Definition: path.h:62
float KyFloat32
float
Definition: types.h:32
const NavTag * GetCurrentOrPreviousNavTag() const
Returns a pointer to the navTag along the path before the position on path.
Definition: positiononlivepath.inl:153
3d vector using 32bits floating points.
Definition: vec3f.h:16
void InitOnPathFirstNode(Path *path)
The 5 Init functions initialize the positionOnPath, but they also clear all the data concerning the l...
Definition: positiononlivepath.inl:48