gwnavruntime/path/pathvalidityinterval.h Source File

pathvalidityinterval.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 
25 
26 namespace Kaim
27 {
28 
29 class LivePath;
30 
31 
32 enum UpperBoundType
33 {
34  UpperBoundType_PathLastNode = 0, // UpperBound is the last node of the Path
35  UpperBoundType_ValidityUpperBound, // UpperBound is the upper limit of the validity interval, Path is known to be invalid after it
36  UpperBoundType_PathInvalid, // Whole Path is considered invalid, no UpperBound
37  UpperBoundType_Temporary, // UpperBound is at a temporary position, validity after it is unknown but will be validated further in next frames
38  UpperBoundType_NoPath // No path, no UpperBound
39 };
40 
43 {
46 
49 
52 
56 
62 
67 
72 
77 
81 };
82 
83 
84 inline const char* ToString(PathValidityStatus e)
85 {
86  static const char* s_strs[] =
87  {
88  "PathValidityStatus_NoPath",
89  "PathIsValid",
90  "ValidityIntervalMustBeRecomputed",
91  "ValidityIsBeingChecked",
92  "Dirty_ProgressInvalid",
93  "Dirty_InvalidBeforeProgress_ProcessingAfter",
94  "Dirty_InvalidBeforeProgress_ValidAfter",
95  "Dirty_ValidBeforeProgress_InvalidAfter",
96  "Dirty_InvalidBeforeAndAfterProgress"
97  };
98  const KyInt32 enumCount = Dirty_InvalidBeforeAndAfterProgress + 1;
99  KY_COMPILER_ASSERT(enumCount == sizeof(s_strs) / sizeof(const char*));
100  KyInt32 idx = (KyInt32)e;
101  return idx >= 0 && idx < enumCount ? s_strs[idx] : "PathValidityStatus_UNKNOWN";
102 }
103 
104 template <class OSTREAM>
105 inline OSTREAM& operator<<(OSTREAM& os, PathValidityStatus e) { os << ToString(e); return os; }
106 
107 
108 
111 {
112 public:
113  // ------------------------------ Functions -----------------------------
114 
117  void Clear();
118  void ClearBounds();
119  void ClearBoundsAndEventList();
120 
121  UpperBoundType GetUpperBoundType() const;
122  PathValidityStatus GetPathValidityStatus() const;
123 
124  void SetPathValidityStatus(PathValidityStatus status);
125 
126  template<class TraverseLogic>
127  KyResult ReStartIntervalComputation(Path* path, void* traverseLogicUserData, const PositionOnPath& targetOnPath,
128  KyFloat32 minDistanceFromTargetOnPathBackward, KyFloat32 minDistanceFromTargetOnPathForward);
129 
130  enum FirstNewIntervalExtendedStatus
131  {
132  FirstNewIntervalIsNotAnExtension,
133  FirstNewIntervalIsAnExtension
134  };
135 
136  // if minimumDistanceAdvancement is 0, validate until the end of the path
137  template<class TraverseLogic>
138  KyResult ValidateForward(Path* path, void* traverseLogicUserData,
139  FirstNewIntervalExtendedStatus* firstIntervalStatus, KyFloat32 minimumDistanceAdvancement = 0.0f);
140 
141 
142 private:
143  KyResult ValidateTargetOnPath(PositionOnPath& targetOnPath);
144 
145  // if minimumdrawBackDistance is 0, validate until the beginning of the path
146  template<class TraverseLogic>
147  KyResult ValidateBackWard(Path* path, void* traverseLogicUserData, KyFloat32 minimumdrawBackDistance = 0.0f);
148 
149  template<class TraverseLogic>
150  KyResult TestCanGoToPrevPathNode(Path* path, void* traverseLogicUserData);
151  template<class TraverseLogic>
152  KyResult TestCanGoToNextPathNode(Path* path, void* traverseLogicUserData, FirstNewIntervalExtendedStatus* firstNewInterval);
153 
154  template<class TraverseLogic>
155  void FindLastValidPositionForward(Path* path, void* traverseLogicUserData, FirstNewIntervalExtendedStatus* firstNewInterval);
156  template<class TraverseLogic>
157  void FindLastValidPositionBackward(Path* path, void* traverseLogicUserData);
158 
159  template<class TraverseLogic>
160  void ValidateNavTagTransitionsBackward(void* traverseLogicUserData, const LogicDoNotUseCanEnterNavTag& navTagType);
161  template<class TraverseLogic>
162  void ValidateNavTagTransitionsBackward(void* traverseLogicUserData, const LogicDoUseCanEnterNavTag& navTagType);
163 
164  template<class TraverseLogic>
165  KyResult ValidateNavTagTransitionForward(void* traverseLogicUserData, KyUInt32 firstNewEvent, const LogicDoNotUseCanEnterNavTag& navTagType);
166  template<class TraverseLogic>
167  KyResult ValidateNavTagTransitionForward(void* traverseLogicUserData, KyUInt32 firstNewEvent,
168  const LogicDoUseCanEnterNavTag& navTagType);
169 
170 
171  // No need for traverseLogic since we already check navTags going backwards from the targetOnPath
172  KyResult BuildEventListFromLowerBoundToUpperBound(Path* path);
173 
174  void CreateIntervalForNavTagSubSegment(Path* path, KyUInt32 pathEdgeIdxToMoveOn, FirstNewIntervalExtendedStatus* firstNewInterval)
175  {
176  CreateIntervalsForNavTagSubsegmentButLast(path, pathEdgeIdxToMoveOn, firstNewInterval);
177  const PathEventType lastEventType = GetEventTypeForLastNavTagSubSegment(path, pathEdgeIdxToMoveOn);
178  CreateIntervalForLastNavTagSubSegment(path, pathEdgeIdxToMoveOn, lastEventType, firstNewInterval);
179  m_needToCheckLastEventForRemoval = (lastEventType == PathEventType_OnNavMeshPathNode);
180  }
181  void CreateIntervalsForNavTagSubsegmentButLast(Path* path, KyUInt32 pathEdgeIdxToMoveOn, FirstNewIntervalExtendedStatus* firstNewInterval);
182  void CreateIntervalForLastNavTagSubSegment(Path* path, KyUInt32 pathEdgeIdxToMoveOn, PathEventType typeOfLastEvent, FirstNewIntervalExtendedStatus* firstNewInterval);
183  void CheckIfLastEventShouldBeRemoved(const NavTagSubSegment& incomingNavTagSubSegment, FirstNewIntervalExtendedStatus* firstNewInterval);
184 
185  PathEventType GetEventTypeForLastNavTagSubSegment(Path* path, KyUInt32 pathEdgeIdxToMoveOn);
186  void CreateIntervalForGraphEdge(Path* path, KyUInt32 pathEdgeIdxToMoveOn);
187  void CreateIntervalForOutsideAlongGraphEdge(Path* path, KyUInt32 pathEdgeIdxToMoveOn);
188  void CreateIntervalForFromOutsidePathEdge(Path* path, KyUInt32 pathEdgeIdxToMoveOn);
189  void CreateIntervalForToOutsidePathEdge(Path* path, KyUInt32 pathEdgeIdxToMoveOn);
190 
191  PathEventType GetEventTypeFromLowerBound(Path* path, const PositionOnPath& posOnPath);
192  void SetPathEventStatusForLastEvent(PathEventStatusInList status);
193 
194  void CreateNewPathEvent(Path* path, KyUInt32 pathEdgeIdxToMoveOn, PathEventType pathEventType, const NavTagPtr& navTagptr);
195 
196  template<class TraverseLogic>
197  KyResult ValidateChannelSection(void* traverseLogicUserData, Path* path, KyUInt32 edgeIdx);
198 
199  template<class TraverseLogic>
200  KyResult ValidateChannelSection(void* traverseLogicUserData, Path* path, const ChannelSectionPtr &channelSectionPtr);
201  template<class TraverseLogic>
202  KyResult ValidateTriangle(void* traverseLogicUserData, Path* path, const Vec3f& a, const Vec3f& b, const Vec3f& c);
203  template<class TraverseLogic>
204  KyResult ValidateConvexQuad(void* traverseLogicUserData, Path* path, const Vec3f& a, const Vec3f& b, const Vec3f& c, const Vec3f& d);
205  template<class TraverseLogic, class EdgeIntersector>
206  KyResult PerformBreadthFirstSearchTraversal(void* traverseLogicUserData, Path* path, EdgeIntersector& intersector);
207 
208  template<class TraverseLogic>
209  KyResult ValidateChannelExtension(void* traverseLogicUserData, Path* path, const KyArray<Vec2f>& polyline);
210 
211 public: // internal
212  PathEventList m_pathEventList;
213 
214  PositionOnPath m_upperBound;
215  PositionOnPath m_lowerBound;
216 
217  NavTrianglePtr m_upperTrianglePtr;
218  NavTrianglePtr m_lowerTrianglePtr;
219 
220  PathValidityStatus m_pathValidityStatus;
221 
222  bool m_needToCheckLastEventForRemoval;
223  bool m_needToValidateChannelSections;
224 };
225 
226 }
227 
229 
The Path validity around the progress of the bot on path is limited:
Definition: pathvalidityinterval.h:76
No Path has been set yet.
Definition: pathvalidityinterval.h:45
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
PathValidityInterval bound specific: bound reached start or end of the path or the max distance of va...
Definition: patheventlist.h:31
The Path has been completely checked and is valid.
Definition: pathvalidityinterval.h:48
NavData have changed around the Path, its validation is about to start.
Definition: pathvalidityinterval.h:51
This class represents a NavTag sub-segment of a ray (within a RayCastQuery or a RayCanGoQuery, carried out against the NavMesh).
Definition: navtagsubsegment.h:39
PathValidityStatus
Enumerate the different validity status of a LivePath.
Definition: pathvalidityinterval.h:42
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:162
The validation can not be processed at all.
Definition: pathvalidityinterval.h:61
Each instance of this class uniquely identifies a single NavFloor.
Definition: navtagptr.h:21
The Path is currently under validation.
Definition: pathvalidityinterval.h:55
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
PathEventStatusInList
Defines the PathEvent status relative to its place in the PathEventList.
Definition: patheventlist.h:39
The Path validity around the progress of the bot on path is limited:
Definition: pathvalidityinterval.h:66
Maintains runtime validity information on a given Path.
Definition: pathvalidityinterval.h:110
std::int32_t KyInt32
int32_t
Definition: types.h:24
The Path validity around the progress of the bot on path is limited:
Definition: pathvalidityinterval.h:71
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:17
The Path validity around the progress of the bot on path is limited: both backward and forward valida...
Definition: pathvalidityinterval.h:80
Tag type used for function overloading in templates. It will be set as a nested typedef in CustomTrav...
Definition: traverselogic.h:54
Tag type used for function overloading in templates. It will be set as a nested typedef in CustomTrav...
Definition: traverselogic.h:51
The class representing a path.
Definition: path.h:62
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16
PathEventType
Defines the different kinds of PathEvent.
Definition: patheventlist.h:20