gwnavruntime/path/positiononlivepath.h Source File

positiononlivepath.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: JUBA
9 
10 #ifndef Navigation_PositionOnLivePath_H
11 #define Navigation_PositionOnLivePath_H
12 
18 
19 
20 namespace Kaim
21 {
22 
23 class Bot;
24 class IMovePositionOnLivePathPredicate;
25 
28 {
32 };
33 
34 
47 {
48  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Path)
49 
50 public:
51  // ---------------------------------- Main API Functions ----------------------------------
52 
54  void BindToPathEventList(PathEventList* pathEventList);
55  PathEventList* GetPathEventList() const { return m_pathEventList; }
56 
57  void Clear();
58  void ClearEventListLocation();
59 
60 
61  // ---------------------------------- Comparison Operators ----------------------------------
62 
63  bool operator==(const PositionOnLivePath& positionOnLivePath) const;
64  bool operator!=(const PositionOnLivePath& positionOnLivePath) const;
65 
66 
67  // ---------------------------------- Raw Path Related Functions ----------------------------------
68 
69  Path* GetPath();
70  const Path* GetPath() const;
71  const Vec3f& GetPosition() const;
72  const PositionOnPath& GetPositionOnPath() const;
73  PositionOnPathStatus GetPositionOnPathStatus() const;
74  PathEdgeType GetPathEdgeType() const;
75 
76  bool IsAtFirstNodeOfPath() const;
77  bool IsAtLastNodeOfPath() const;
78 
79  bool IsAtFirstEdgeOfPath() const;
80  bool IsAtLastEdgeOfPath() const;
81 
85  KyUInt32 GetPathEdgeIndex() const;
86 
91 
94 
97 
102 
105  bool DoesPrecede(const PositionOnLivePath& other) const;
106 
109  bool IsStrictlyBefore(const PositionOnLivePath& other) const;
110 
111  // ---------------------------------- PositionOnLivePath initialization on Path----------------------------------
115 
116  void InitOnPathFirstNode(Path* path);
117  void InitOnPathLastNode(Path* path);
118  void InitOnPathNode(Path* path, KyUInt32 pathNodeIdx);
119  void InitOnPathEdge(Path* path, const Vec3f& positionOnEdge, KyUInt32 pathEdgeIdx);
120  void InitOnPositionOnPath(const PositionOnPath& positionOnPath);
121 
124 
125  // ---------------------------------- PathEventList Related Functions ----------------------------------
126 
127  OnEventListStatus GetOnEventListStatus() const;
128 
129  PathEvent GetPathEvent(KyUInt32 pathEventIdx) const;
130  PathEvent GetCurrentPathEvent() const; // return copy of current PathEvent _if and only if_ on a PathEvent!
131 
136 
143 
150 
151  bool IsAtLowerBoundOfLivePath() const;
152  bool IsAtUpperBoundOfLivePath() const;
153 
155  bool IsAtACheckPoint() const;
156 
163 
170  const NavTag* GetCurrentOrNextNavTag() const;
171 
178  const NavTag* GetCurrentOrPreviousNavTag() const;
179 
180 
181  // ---------------------------------- Move Functions ----------------------------------
182 
187  void MoveForward(KyFloat32 distanceMove);
188 
193  void MoveBackward(KyFloat32 distanceMove);
194 
200  void MoveForward_StopAtPathNode(KyFloat32 distanceMove);
201 
207  void MoveBackward_StopAtPathNode(KyFloat32 distanceMove);
208 
213  void MoveForward_StopAtEvent(KyFloat32 distanceMove);
214 
219  void MoveBackward_StopAtEvent(KyFloat32 distanceMove);
220 
227 
234 
237 
240 
246  void MoveForward_StopAtCheckPoint(KyFloat32 distanceMove);
247 
252 
257 
260  void MoveToPathEvent(KyUInt32 pathEventIdx);
261 
266 
271 
276 
281 
286 
291 
296 
302 
306 
310 
314  void SetNewPositionOnPathForward(const PositionOnPath& newPositionOnPathForward);
315 
319  void SetNewPositionOnPathBackward(const PositionOnPath& newPositionOnPathBackward);
320 
321  // ---------------------------------- Move Functions with Cost ----------------------------------
322 
329  template<class TraverseLogic>
330  void MoveForwardAndGetCost_StopAtEventOrAtPathNode(void* traverseLogicUserData, KyFloat32 distanceMove, RayCanGoMarginMode rayCanGoMarginMode, KyFloat32& cost);
331 
332 
333  // ---------------------------------- Unsafe Version of Functions ----------------------------------
335 
336  // cf. GetNextPathEventIdx()
337  KyUInt32 GetNextPathEventIdx_Unsafe() const;
338  // cf. GetPrevPathEventIdx()
339  KyUInt32 GetPrevPathEventIdx_Unsafe() const;
340  // cf. MoveForwardToNextPathEvent()
341  void MoveForwardToNextPathEvent_Unsafe();
342  // cf. MoveBackwardToPrevPathEvent()
343  void MoveBackwardToPrevPathEvent_Unsafe();
344  // cf. MoveForwardToNextPathEventInterval()
345  void MoveForwardToNextPathEventInterval_Unsafe();
346 
347 public: // DEPRECATED
348  // ------------- Deprecated functions --------------
349  KY_DEPRECATED(const NavTag* GetUpcomingEventNavTag() const) { return GetCurrentOrNextNavTag(); }
350  KY_DEPRECATED(const NavTag* GetPreviousEventNavTag() const) { return GetCurrentOrPreviousNavTag(); }
351 
352 private:
353  bool IsEventListStatusValid() const;
354 
355  void FixLocationOnEventListAfterMovingForward();
356  void FixLocationOnEventListAfterMovingBackward();
357  void StopAtEventAfterMovingForward();
358  void StopAtEventAfterMovingBackward();
359  void StopAtCheckPointAfterMovingForward();
360 
361  template<class TraverseLogic>
362  void GetCostAfterStopAtEventOrAtPathNode(void* traverseLogicUserData, const Vec3f& posBeforeMove, const NavTag* navTag,
363  RayCanGoMarginMode rayCanGoMarginMode, KyFloat32& cost, const LogicWithoutCostMultipler&);
364  template<class TraverseLogic>
365  void GetCostAfterStopAtEventOrAtPathNode(void* traverseLogicUserData, const Vec3f& posBeforeMove, const NavTag* navTag,
366  RayCanGoMarginMode rayCanGoMarginMode, KyFloat32& cost, const LogicWithCostMultiplerPerNavTag&);
367  template<class TraverseLogic>
368  void GetCostAfterStopAtEventOrAtPathNode(void* traverseLogicUserData, const Vec3f& posBeforeMove, const NavTag* navTag,
369  RayCanGoMarginMode rayCanGoMarginMode, KyFloat32& cost, const LogicWithCostMultiplerPerTriangle&);
370 
371 private:
372  PathEventList* m_pathEventList;
373  PositionOnPath m_positionOnPath;
374  OnEventListStatus m_onEventListStatus;
375  KyUInt32 m_currentOnEventListIdx; // index on the event or index of the interval. position is on ]EventIntervalStart, EventIntervalEnd]
376 };
377 
378 } // namespace Kaim
379 
381 
382 #endif // Navigation_PositionOnLivePath_H
void MoveForward_StopAtCheckPoint(KyFloat32 distanceMove)
This function moves forward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:392
OnEventListStatus
Enumerates the admissible values for PositionOnLivePath status accordingly to its position relatively...
Definition: positiononlivepath.h:27
void MoveBackwardToPrevPathNode()
This function moves backward the position up to the previous Path node.
Definition: positiononlivepath.inl:436
void MoveBackwardToPreviousEventWithPredicate(IMovePositionOnLivePathPredicate *predicate)
This function will move positionOnLivePath backward until the predicate returns false.
This class aggregates all necessary information about a position on a Path, namely: ...
Definition: positiononpath.h:33
void MoveBackward_StopAtPathNode(KyFloat32 distanceMove)
This function moves backward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:480
PathEventList aggregates all PathEvents and PathEventIntervals in a PathValidityInterval.
Definition: patheventlist.h:141
void MoveToPathEvent(KyUInt32 pathEventIdx)
This function moves the position to the specified path event.
Definition: positiononlivepath.inl:307
void MoveForwardToNextPathNode()
This function moves forward the position up to the next Path node.
Definition: positiononlivepath.inl:425
PositionOnPathStatus
< enumerates="" the="" different="" status="" an="" objectpositiononpath="" can="" have="" on="" its="" path.="" />
Definition: positiononpath.h:20
bool IsAtACheckPoint() const
Indicates if the PositionOnLIvePath is at an event that is a check point.
Definition: positiononlivepath.inl:44
void MoveForwardToNextPathEdge()
This function moves forward the position up to the start of the next path edge.
Definition: positiononlivepath.inl:447
void MoveToNextEventOrPathNode()
This function moves forward the position until an event or a pathNode is reached. ...
Definition: positiononlivepath.inl:370
The PositionOnLivePath is on a PathEvent.
Definition: positiononlivepath.h:30
void MoveForwardToNextPathEvent()
This function moves forward the position up to the next path event.
Definition: positiononlivepath.inl:319
KyUInt32 GetNextPathEventIdx() const
This function has to be used carefully:
Definition: positiononlivepath.inl:284
The PositionOnLivePath is strictly on a PathEventInterval.
Definition: positiononlivepath.h:31
void MoveBackwardToPrevPathEdge()
This function moves forward the position up to the start of the next path edge.
Definition: positiononlivepath.inl:458
The PositionOnLivePath relative position in PathEventList is not yet defined.
Definition: positiononlivepath.h:29
void SetNewPositionOnPathBackward(const PositionOnPath &newPositionOnPathBackward)
Moves this PositionOnLivePath backward to the provided PositionOnPath and updates PathEventList relat...
Definition: positiononlivepath.inl:513
void MoveForward_StopAtEventOrAtPathNode(KyFloat32 distanceMove)
This function moves forward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:348
void MoveForwardToNextPathEventInterval()
This function moves forward the position up to the next path event interval.
Definition: positiononlivepath.inl:338
void FindLocationOnEventListFromScratch()
This function computes the location on the PathEventList from the PositionOnPath. ...
void MoveBackwardToPrevCheckPoint()
This function moves backward the position up to the previous path event that is a check point...
PathEdgeType GetEdgeTypeToMoveOnForward() const
return the type of the edge given by GetEdgeIdxToMoveOnForward()
Definition: positiononlivepath.inl:25
Interface used to verify a PositionOnPath can be moved forward along the Path.
Definition: imovepositiononpathpredicate.h:19
RayCanGoMarginMode
Defines the different mode for the NavMesh border margin to be used in RayCanGo queries.
Definition: database.h:41
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:201
A PathEvent is a particular PositionOnPath which feature is specified by a PathEventType.
Definition: patheventlist.h:62
KyUInt32 GetEdgeIdxToMoveOnForward() const
If this in on a Path node, it returns the index of the edge starting at this path node...
Definition: positiononlivepath.inl:23
void MoveForward_StopAtEvent(KyFloat32 distanceMove)
This function moves forward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:100
void MoveForwardToNextPathEventWithPredicate(IMovePositionOnLivePathPredicate *predicate)
This function will move positionOnLivePath forward until the predicate returns false.
Definition: gamekitcrowddispersion.h:20
void MoveBackward_StopAtEvent(KyFloat32 distanceMove)
This function moves backward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:111
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
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 it lies on.
Definition: positiononlivepath.inl:24
#define KY_DEPRECATED(f)
Macro to mark a function, class or method as deprecated.
Definition: types.h:289
KyUInt32 GetOnEventListIndex() const
This function has to be used carefully:
Definition: positiononlivepath.inl:32
void MoveBackward(KyFloat32 distanceMove)
This function moves backward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:414
const NavTag * GetCurrentOrNextNavTag() const
Returns a pointer to the navTag along the path after the position on path.
Definition: positiononlivepath.inl:151
KyUInt32 GetPrevPathEventIdx() const
This function has to be used carefully:
Definition: positiononlivepath.inl:295
void MoveBackwardToPrevPathEvent()
This function moves backward the position up to the previous path event.
Definition: positiononlivepath.inl:329
PathEdgeType
Defines the different kind of PathEdge within a Path.
Definition: path.h:26
PathEdgeType GetEdgeTypeToMoveOnBackward() const
return the type of the edge given by GetEdgeIdxToMoveOnBackward()
Definition: positiononlivepath.inl:26
This class aggregates all necessary information to describe a position on a LivePath, namely:
Definition: positiononlivepath.h:46
bool DoesPrecede(const PositionOnLivePath &other) const
Returns true when this PositionOnLivePath precede or is at same position on the Path that the other o...
Definition: positiononlivepath.inl:51
KyFloat32 MoveForwardToClosestPositionOnPath(const Vec3f &position)
Move forward to the closest position on path from originalPosition.
Definition: positiononlivepath.inl:491
void MoveForward(KyFloat32 distanceMove)
This function moves forward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:403
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
void SetNewPositionOnPathForward(const PositionOnPath &newPositionOnPathForward)
Moves this PositionOnLivePath forward to the provided PositionOnPath and updates PathEventList relate...
Definition: positiononlivepath.inl:504
void MoveBackward_StopAtEventOrAtPathNode(KyFloat32 distanceMove)
This function moves backward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:359
void MoveForwardToNextCheckPoint()
This function moves forward the position up to the next path event that is a check point...
KyUInt32 GetPathEdgeIndex() const
If this is at a Path node, it returns the index of the edge ending at this Path node, except if it is at the first Path node, in which case it returns the first edge index (0).
Definition: positiononlivepath.inl:22
void MoveToPrevEventOrPathNode()
This function moves backward the position until an event or a pathNode is reached.
Definition: positiononlivepath.inl:381
void MoveForward_StopAtPathNode(KyFloat32 distanceMove)
This function moves forward the position along distanceMove meters measured on the broken-line...
Definition: positiononlivepath.inl:469
const PositionOnPath * GetUpcomingEventPositionOnPath() const
Returns a pointer to the PositionOnPath along the path after positionOnLivePath.
Definition: positiononlivepath.inl:123
The class representing a path.
Definition: path.h:42
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
bool IsStrictlyBefore(const PositionOnLivePath &other) const
Returns true when this PositionOnLivePath precede than the other one; returns false if it as as the s...
Definition: positiononlivepath.inl:52
const NavTag * GetCurrentOrPreviousNavTag() const
Returns a pointer to the navTag along the path before the position on path.
Definition: positiononlivepath.inl:175
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23
void InitOnPathFirstNode(Path *path)
The 5 Init functions initialize the positionOnPath, but they also clear all the data concerning the l...
Definition: positiononlivepath.inl:70