gwnavruntime/queries/ipathfinderquery.h Source File

ipathfinderquery.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 
13 #include "gwnavruntime/path/path.h"
17 
18 namespace Kaim
19 {
20 
21 class DisplayList;
22 
26 {
27  PATHFINDER_DO_NOT_COMPUTE_CHANNELS,
28  PATHFINDER_DO_COMPUTE_CHANNELS,
29 };
30 
35 {
36 public:
39  {
46  };
47 
48  // ------------------------------ Functions -----------------------------
49 
51  virtual ~IPathFinderQuery() {}
52 
53  Path* GetPath() const { return m_path; }
54  const Vec3f& GetStartPos() const { return m_startPos3f; }
55 
56  void SetNavigationProfileId(KyUInt32 navigationProfileId) { m_navigationProfileId = navigationProfileId; }
57  KyUInt32 GetNavigationProfileId() const { return m_navigationProfileId; }
58 
59  // ---------------------------------- Virtual Member Functions ----------------------------------
60 
62  virtual const Vec3f* GetDestination() const = 0;
63 
65  virtual void GetPathFinderTextResult(String&) const {}
66 
68  virtual void DisplayPropagationBounds(DisplayList&) const {}
69 
70  virtual PathFinderResult GetPathFinderResult() const = 0;
71 
72 protected:
73  void SetPath(Path* path) { m_path = path; }
74  void BindToDatabase(Database* database);
75  void Initialize();
76 
77 public:
78  // ---------------------------------- Public Data Members ----------------------------------
79  KyUInt32 m_navigationProfileId;
80 
81  // start
83 
84  // configuration
87  FullDebug m_fullDebug;
88  bool m_doClampRawPath; // only useful for tests
89 
90  // computed
91  KyUInt32 m_lastAdvanceDatabaseChangeIdx; // used to test if there was a change in the database since last call to Advance
92 
93  // result
94  Ptr<Path> m_path;
95 };
96 
97 KY_INLINE IPathFinderQuery::IPathFinderQuery()
98  : m_navigationProfileId(0)
99  , m_computeChannelMode(PATHFINDER_DO_NOT_COMPUTE_CHANNELS)
100  , m_doClampRawPath(true)
101  , m_lastAdvanceDatabaseChangeIdx(0)
102  , m_path(nullptr)
103 {}
104 
105 KY_INLINE void IPathFinderQuery::BindToDatabase(Database* database)
106 {
108 
109  // start
110  m_startPos3f.Zero();
111 
112  // configuration
113  m_computeChannelMode = PATHFINDER_DO_NOT_COMPUTE_CHANNELS;
114  m_channelComputerConfig.SetDefaults();
115  m_fullDebug.Clear();
116  m_doClampRawPath = true;
117 
118  // computed
119  m_lastAdvanceDatabaseChangeIdx = 0;
120 
121  // result
122  m_path = nullptr;
123 }
124 
125 KY_INLINE void IPathFinderQuery::Initialize()
126 {
128 
129  // start
130  m_startPos3f.Zero();
131 
132  // computed
133  m_lastAdvanceDatabaseChangeIdx = 0;
134 
135  // result
136  m_path = nullptr;
137 }
138 
142 {
143 public:
144  ScopedSetPathNavigationProfile(IPathFinderQuery* query) : m_query(query) {}
146  {
147  if (m_query->m_path)
148  m_query->m_path->SetNavigationProfileId(m_query->GetNavigationProfileId());
149  }
150  IPathFinderQuery* m_query;
151 };
152 
153 }
154 
155 
ChannelComputerConfig m_channelComputerConfig
The parameter set specific to Channels computation.
Definition: ipathfinderquery.h:86
Base class for all pathfinder queries.
Definition: ipathfinderquery.h:34
PathFinderQueryComputeChannelMode
This enum tells if the PathFinderQuery should compute Channels around path sections laying on the Nav...
Definition: ipathfinderquery.h:25
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
Class that aggregates parameters that allow to configure the channel computation of a Bot...
Definition: channelcomputerconfig.h:89
static Vec3f Zero()
Returns {0.0f, 0.0f, 0.0f}.
Definition: vec3f.h:99
The IPathFinderQuery ended prematurely due to changes into NavData.
Definition: ipathfinderquery.h:45
Ptr< Path > m_path
The Path found by the query.
Definition: ipathfinderquery.h:94
Vec3f m_startPos3f
The starting position for the Path request.
Definition: ipathfinderquery.h:82
PathFinderQueryComputeChannelMode m_computeChannelMode
The mode toggling Channels computation.
Definition: ipathfinderquery.h:85
Base class for all the queries that need to be time-sliced.
Definition: iquery.h:262
The IPathFinderQuery has been completed but no Path has been found.
Definition: ipathfinderquery.h:44
The IPathFinderQuery has been completed and a Path has been found.
Definition: ipathfinderquery.h:43
virtual void DisplayPropagationBounds(DisplayList &) const
Fill the displayList with display info that may help to understand a PathFinderFailure (mainly propag...
Definition: ipathfinderquery.h:68
DisplayList is used to push text, lines or shapes for rendering in the NavigationLab e...
Definition: displaylist.h:128
virtual void GetPathFinderTextResult(String &) const
Fills the String with an explanation of the result. Use this to debug your pathfinder query...
Definition: ipathfinderquery.h:65
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
void BindToDatabase(Database *database)
Should be called by the derived class before Initializing the query Sets m_database and sets m_traver...
Definition: iquery.h:207
PathFinderResult
Enumerates the possible status of a IPathFinderQuery.
Definition: ipathfinderquery.h:38
Gathers all runtime flags used to debug internal algorithms (mostly PathFinder).
Definition: fulldebug.h:14
The IPathFinderQuery is initialized but has not been processed.
Definition: ipathfinderquery.h:41
The IPathFinderQuery is currently under process.
Definition: ipathfinderquery.h:42
void Initialize()
Should be called by the derived class before trying to perform the query or to push it in a QueryQueu...
Definition: iquery.h:273
virtual const Vec3f * GetDestination() const =0
This function is virtual because not all the PathFinders have a preset destination, it may return nullptr.
The IPathFinderQuery is not yet initialized.
Definition: ipathfinderquery.h:40
The class representing a path.
Definition: path.h:62
3d vector using 32bits floating points.
Definition: vec3f.h:16
utility class used to set to the SetNavigationProfileId of the path easily created on the stack at th...
Definition: ipathfinderquery.h:141