gwnavruntime/pathfollower/targetonpath.h Source File

targetonpath.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 #pragma once
8 
11 #include "gwnavruntime/world/bot.h"
12 
13 
14 namespace Kaim
15 {
16 
19 {
23 
28 
33 
38 
41 };
42 KY_INLINE const char* GetTargetOnPathStatusDescription(TargetOnPathStatus status)
43 {
44  switch (status)
45  {
46  case TargetOnPathNotInitialized: return "NotInitialized";
47  case TargetOnPathUnknownReachability: return "UnknownReachability";
48  case TargetOnPathInInvalidNavData: return "InInvalidNavData";
49  case TargetOnPathNotReachable: return "NotReachable";
50  case TargetOnPathReachable: return "Reachable";
51  }
52  return "Undefined";
53 }
54 
55 class TargetOnPath
56 {
57 public:
58  TargetOnPath() { Clear(); }
59 
60  void Clear()
61  {
62  m_positionOnLivePath.Clear();
63  m_status = TargetOnPathNotInitialized;
64  m_marginMode = NoMargin;
65  m_nextShortcutSqDistTrigger = -1.f;
66  }
67 
69  bool IsTargetNotReachableOnNavMesh(const Bot* bot) const
70  {
71  return ((m_positionOnLivePath.GetPositionOnPathStatus() == PositionOnPathStatus_Undefined) ||
72  ((m_status == TargetOnPathNotReachable) &&
73  (m_positionOnLivePath.GetEdgeTypeToMoveOnBackward() == Kaim::PathEdgeType_OnNavMesh) &&
74  (bot->GetNavTrianglePtr().IsValid() == true) &&
75  (bot->GetProgressOnLivePathStatus() == ProgressOnPathOnNavMesh)));
76  }
77 
78  // shortcut to m_positionOnLivePath to make code more readable
79  PositionOnLivePath& PosLive() { return m_positionOnLivePath; }
80  const PositionOnLivePath& PosLive() const { return m_positionOnLivePath; }
81 
82  void BindToPathEventList(PathEventList* pathEventList) { m_positionOnLivePath.BindToPathEventList(pathEventList); }
83 
84  PathEventList* GetPathEventList() const { return m_positionOnLivePath.GetPathEventList(); }
85 
86  Path* GetPath() { return m_positionOnLivePath.GetPath(); }
87  const Path* GetPath() const { return m_positionOnLivePath.GetPath(); }
88  const Vec3f& GetPosition() const { return m_positionOnLivePath.GetPosition(); }
89  const PositionOnPath& GetPositionOnPath() const { return m_positionOnLivePath.GetPositionOnPath(); }
90  PositionOnPathStatus GetPositionOnPathStatus() const { return m_positionOnLivePath.GetPositionOnPathStatus(); }
91  PathEdgeType GetPathEdgeType() const { return m_positionOnLivePath.GetPathEdgeType(); }
92  bool IsAtFirstNodeOfPath() const { return m_positionOnLivePath.IsAtFirstNodeOfPath(); }
93  bool IsAtLastNodeOfPath() const { return m_positionOnLivePath.IsAtLastNodeOfPath(); }
94  bool IsAtFirstEdgeOfPath() const { return m_positionOnLivePath.IsAtFirstEdgeOfPath(); }
95  bool IsAtLastEdgeOfPath() const { return m_positionOnLivePath.IsAtLastEdgeOfPath(); }
96  KyUInt32 GetPathEdgeIndex() const { return m_positionOnLivePath.GetPathEdgeIndex(); }
97  KyUInt32 GetEdgeIdxToMoveOnForward() const { return m_positionOnLivePath.GetEdgeIdxToMoveOnForward(); }
98  PathEdgeType GetEdgeTypeToMoveOnForward() const { return m_positionOnLivePath.GetEdgeTypeToMoveOnForward(); }
99  PathEdgeType GetEdgeTypeToMoveOnBackward() const { return m_positionOnLivePath.GetEdgeTypeToMoveOnBackward(); }
100  KyUInt32 GetEdgeIdxToMoveOnBackward() const { return m_positionOnLivePath.GetEdgeIdxToMoveOnBackward(); }
101 
102  OnEventListStatus GetOnEventListStatus() const { return m_positionOnLivePath.GetOnEventListStatus(); }
103  KyUInt32 GetOnEventListIndex() const { return m_positionOnLivePath.GetOnEventListIndex(); }
104 
105  bool IsAtUpperBoundOfLivePath() const { return m_positionOnLivePath.IsAtUpperBoundOfLivePath(); }
106  bool IsAtACheckPoint() const { return m_positionOnLivePath.IsAtACheckPoint(); }
107 
108  void MoveForward_StopAtCheckPoint(KyFloat32 distanceMove) { m_positionOnLivePath.MoveForward_StopAtCheckPoint(distanceMove); }
109 
110  bool IsAtLowerBoundOfLivePath() const { return m_positionOnLivePath.IsAtLowerBoundOfLivePath(); }
111  void SetNewPositionOnPathBackward(const PositionOnPath& posPath) { m_positionOnLivePath.SetNewPositionOnPathBackward(posPath); }
112 
113 public:
114  // ----- State members -----
115  PositionOnLivePath m_positionOnLivePath;
116  TargetOnPathStatus m_status;
117 
118  // ----- Computation members -----
119  RayCanGoMarginMode m_marginMode; // margin to use to validate the TargetOnPath
120  KyFloat32 m_nextShortcutSqDistTrigger; // distance used to trigger a new computation of the target, it is updated when recomputing the target
121 };
122 
123 }
124 
OnEventListStatus
Enumerates the admissible values for PositionOnLivePath status accordingly to its position relatively...
Definition: positiononlivepath.h:24
Target on path is initialized but not validated.
Definition: targetonpath.h:27
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
PositionOnPathStatus
< enumerates="" the="" different="" status="" an="" objectpositiononpath="" can="" have="" on="" its="" path.="" />
Definition: positiononpath.h:17
Target on path is reachable in straight line.
Definition: targetonpath.h:40
TargetOnPathStatus
Enumerates the possible status values of Bot Position on path.
Definition: targetonpath.h:18
The PositionOnPath is not yet defined.
Definition: positiononpath.h:19
Target on path was on a valid NavData that has been streamed out (due to explicit streaming or Dynami...
Definition: targetonpath.h:32
Target on path is no more reachable in straight line.
Definition: targetonpath.h:37
RayCanGoMarginMode
Defines the different mode for the NavMesh border margin to be used in RayCanGo queries.
Definition: database.h:37
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Margin to be used to get ray can go exactly on the NavMesh borders.
Definition: database.h:39
The PathEdge has been computed on the NavMesh.
Definition: path.h:25
Position on path has not been yet initialized at all.
Definition: targetonpath.h:22
float KyFloat32
float
Definition: types.h:32