gwnavruntime/queries/findfirstvisiblepositiononpathquery.h Source File

findfirstvisiblepositiononpathquery.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: NOBODY
9 #ifndef Navigation_FindFirstVisiblePositionOnPathQuery_H
10 #define Navigation_FindFirstVisiblePositionOnPathQuery_H
11 
16 
17 
18 namespace Kaim
19 {
20 
25 template<class TraverseLogic>
26 class FindFirstVisiblePositionOnPathQuery : public BaseFindFirstVisiblePositionOnPathQuery
27 {
28 public:
29  // ---------------------------------- Public Member Functions ----------------------------------
30 
33 
34  // ---------------------------------- Functions to set up the query ----------------------------------
35 
39  void BindToDatabase(Database* database);
40 
47  void Initialize(const PositionOnPath& startPositionOnPath, const PositionOnPath& endPositionOnPath, const Vec3f& visibilityStartPoint);
48 
49  // ---------------------------------- write accessors for query inputs ----------------------------------
50 
54  void SetVisibilityStartTrianglePtr(const NavTrianglePtr& visibilityStartTrianglePtr);
55 
56  // ---------------------------------- write accessors for query parameters ----------------------------------
57 
58  void SetSamplingDistance(KyFloat32 samplingDistance);
59 
63  void SetRayCanGoMarginMode(RayCanGoMarginMode rayCanGoMarginMode);
64 
65 
66  // ---------------------------------- Query framework functions ----------------------------------
67 
68  virtual void Advance(WorkingMemory* workingMemory);
69 
73  void PerformQuery(WorkingMemory* workingMemory = KY_NULL);
74 
75  // ---------------------------------- Accessors ----------------------------------
76 
78  const PositionOnPath& GetStartPositionOnPath() const;
79  const PositionOnPath& GetEndPositionOnPath() const;
80  const Vec3f& GetVisibilityStartPoint() const;
81  const NavTrianglePtr& GetVisibilityStartTrianglePtr() const;
82  KyFloat32 GetSamplingDistance() const;
83  const PositionOnPath& GetFirstVisiblePositionOnPath() const;
84 
85 private:
86  CandidateValidationResult ValidateCandidate(
87  RayCanGoQuery<TraverseLogic>& rayCanGoQuery, const PositionOnPath& candidate, WorkingMemory* workingMemory);
88 
89 public:
90  ScopedDisplayList* m_displayList;
91 };
92 
93 // Small utility class that simply wrap a WorkingMemArray<PositionOnPath> to clean it correctly in destructor.
94 class PositionOnPathWorkingMemArray
95 {
96 public:
97  PositionOnPathWorkingMemArray() {}
98 
99  KyResult BindToDatabase(WorkingMemory* workingMemory, KyUInt32 capacity)
100  {
101  m_array.Init(workingMemory);
102 
103  if (m_array.IsInitialized() == false)
104  return KY_ERROR;
105 
106  return m_array.SetMinimumCapacity(capacity);
107  }
108 
109  KyResult PushBack(const PositionOnPath& positionOnPath)
110  {
111  return m_array.PushBack(InternalPositionOnPath(positionOnPath));
112  }
113 
114  void GetPositionOnPath(KyUInt32 index, PositionOnPath& positionOnPath) const
115  {
116  m_array[index].CopyToPositionOnPath(positionOnPath);
117  }
118 
119  KyUInt32 GetCount() const { return m_array.GetCount(); }
120 
121 private:
122  class InternalPositionOnPath
123  {
124  public:
125  InternalPositionOnPath(const PositionOnPath& positionOnPath)
126  {
127  positionOnPath.GetRawValues(m_path, m_position, m_onPathStatus, m_currentIndexOnPath, m_distanceToEndOfPath);
128  }
129 
130  void CopyToPositionOnPath(PositionOnPath& positionOnPath) const
131  {
132  positionOnPath.SetRawValues(m_path, m_position, m_onPathStatus, m_currentIndexOnPath, m_distanceToEndOfPath);
133  }
134 
135  Path* m_path;
136  Vec3f m_position;
137  PositionOnPathStatus m_onPathStatus;
138  KyUInt32 m_currentIndexOnPath;
139  KyFloat32 m_distanceToEndOfPath;
140  };
141 
142  WorkingMemArray<InternalPositionOnPath> m_array;
143 };
144 
145 //class PositionOnPathWorkingMemArray
146 //{
147 //public:
148 // PositionOnPathWorkingMemArray(WorkingMemory* /*workingMemory*/, KyUInt32 /*capacity*/) {}
149 //
150 // KyArray<PositionOnPath> m_array;
151 //};
152 
153 }
154 
156 
157 
158 #endif // Navigation_FindFirstVisiblePositionOnPathQuery_H
159 
FindFirstVisiblePositionOnPathQueryResult
Enumerates the possible results of a FindFirstVisiblePositionOnPathQuery.
Definition: basefindfirstvisiblepositiononpathquery.h:21
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
virtual void Advance(WorkingMemory *workingMemory)
This function is called by the QueryQueue to process one step on the query.
Definition: findfirstvisiblepositiononpathquery.inl:80
This class aggregates all necessary information about a position on a Path, namely: ...
Definition: positiononpath.h:33
void SetRayCanGoMarginMode(RayCanGoMarginMode rayCanGoMarginMode)
Sets the RayCanGoMarginMode value to be used in the ray can go queries.
Definition: findfirstvisiblepositiononpathquery.inl:43
PositionOnPathStatus
< enumerates="" the="" different="" status="" an="" objectpositiononpath="" can="" have="" on="" its="" path.="" />
Definition: positiononpath.h:20
#define KY_NULL
Null value.
Definition: types.h:247
void SetVisibilityStartTrianglePtr(const NavTrianglePtr &visibilityStartTrianglePtr)
Set The NavMesh triangle that corresponds to m_visibilityStartPos3f.
Definition: findfirstvisiblepositiononpathquery.inl:34
The RayCanGoQuery class tests whether or not a ray (with a width of 0) can pass along a straight line...
Definition: raycangoquery.h:24
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:64
RayCanGoMarginMode
Defines the different mode for the NavMesh border margin to be used in RayCanGo queries.
Definition: database.h:41
void PerformQuery(WorkingMemory *workingMemory=0)
Performs the query.
Definition: findfirstvisiblepositiononpathquery.inl:87
Definition: gamekitcrowddispersion.h:20
#define KY_ERROR
Shorthand for Kaim::Result::Failure.
Definition: types.h:272
ScopedDisplayList is used to push text, lines or shapes for rendering in the NavigationLab e...
Definition: displaylist.h:136
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:22
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
The FindFirstVisiblePositionOnPathQuery class searches for a PositionOnPath that can be reached from ...
Definition: findfirstvisiblepositiononpathquery.h:27
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:372
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23
void BindToDatabase(Database *database)
Binds the query with the specified Database, clears all the inputs and outputs and sets all other par...
Definition: findfirstvisiblepositiononpathquery.inl:21