gwnavruntime/queries/trianglefromposquery.h Source File

trianglefromposquery.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 
14 namespace Kaim
15 {
16 
17 class ActiveCell;
18 class NavCell;
19 class NavFloorBlob;
20 template <class T> class WorkingMemArray;
21 
24 {
27 
30 
32 };
33 
36 {
40 };
41 
47 {
48 public:
49  static QueryType GetStaticType() { return TypeTriangleFromPos; }
50  virtual QueryType GetType() const { return TypeTriangleFromPos; }
51  virtual void BuildQueryBlob(BaseBlobHandler* blobHandler);
52  virtual void InitFromQueryBlob(World* world, void* blob);
53  virtual Ptr<BaseBlobHandler> CreateQueryBlobHandler() { return CreateStaticQueryBlobHandler(); }
54  static Ptr<BaseBlobHandler> CreateStaticQueryBlobHandler();
55 
56  // ------------------------------ Functions -----------------------------
57 
58  TriangleFromPosQuery();
59  virtual ~TriangleFromPosQuery() {}
60 
61  // ---------------------------------- Functions to set up the query ----------------------------------
62 
66  void BindToDatabase(Database* database);
67 
72  void Initialize(const Vec3f& pos);
73 
74  // ---------------------------------- write accessors for query parameters ----------------------------------
75 
78  void SetPositionSpatializationRange(const PositionSpatializationRange& positionSpatializationRange);
79 
82  void SetQueryType(TriangleFromPosQueryType queryType);
83 
84 
85  // ---------------------------------- Query framework functions ----------------------------------
86 
87  virtual void Advance(WorkingMemory* workingMemory);
88 
90  void PerformQuery(WorkingMemory* workingMemory = nullptr);
91 
92  // ---------------------------------- Accessors ----------------------------------
93 
94  TriangleFromPosQueryResult GetResult() const;
95  const Vec3f& GetInputPos() const;
96  const NavTrianglePtr& GetResultTrianglePtr() const;
97  TriangleFromPosQueryType GetQueryType() const;
98  KyFloat32 GetAltitudeOfProjectionInTriangle() const;
99 
100  const PositionSpatializationRange& GetPositionSpatializationRange() const;
101 
102 public: // internal
103  void SetInputIntegerPos(const WorldIntegerPos& integerPos);
104  const WorldIntegerPos& GetInputIntegerPos() const;
105  void PerformQueryWithInputCoordPos(WorkingMemory* workingMemory);
106 
107 private:
108  void SetResult(TriangleFromPosQueryResult result);
109  void GetNearestTrianglePtrFromPos(WorkingMemory* workingMemory);
110  KyResult FilterNavFloorsFromAltitudeRange(WorkingMemArray<NavFloor*>& floorIndicesToTest, ActiveCell& activeCell);
111  void ProcessFilteredNavFloors(const WorkingMemArray<NavFloor*>& filteredMetaFloorIndices, const Vec3f& pos3fInCell, KyFloat32 multiplicatorValidyForQueryType);
112  void FindTriangleInFloor(const Vec3f& posInCell, NavFloor* navFloor, const NavFloorBlob* floorBlob, bool& triangleFound, KyFloat32& minDist,
113  KyFloat32 multiplicatorValidyForQueryType);
114 
115 private:
116  WorldIntegerPos m_inputIntegerPos;
117 
119 
121 
126 
130 
133 
135 };
136 
137 }
138 
140 
141 
142 
143 
void SetPositionSpatializationRange(const PositionSpatializationRange &positionSpatializationRange)
Write accessor for m_positionSpatializationRange.
Definition: trianglefromposquery.inl:16
virtual QueryType GetType() const
Get query type.
Definition: trianglefromposquery.h:50
Indicates the query has not yet been initialized.
Definition: trianglefromposquery.h:25
TriangleFromPosQueryResult
Enumerates the possible results of a TriangleFromPosQuery.
Definition: trianglefromposquery.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: trianglefromposquery.cpp:46
Indicates that insufficient working memory caused the query to stop.
Definition: trianglefromposquery.h:29
Vertical range (above, below) that represents the altitude tolerance for a position to be inside the ...
Definition: positionspatializationrange.h:17
virtual void Advance(WorkingMemory *workingMemory)
This function is called by the QueryQueue to process one step on the query.
Definition: trianglefromposquery.inl:10
KyFloat32 m_altitudeInTriangle
Updated during processing to indicate the projected altitude of m_inputPos3f on the triangle stored i...
Definition: trianglefromposquery.h:132
Base class for all the queries that do not need to be time-sliced.
Definition: iquery.h:245
Vec3f m_inputPos3f
input position
Definition: trianglefromposquery.h:118
PositionSpatializationRange m_positionSpatializationRange
The altitude tolerance around m_inputPos3f that will be searched for triangles.
Definition: trianglefromposquery.h:120
TriangleFromPosQueryType m_queryType
An element from the TriangleFromPosQueryType enumeration that indicates whether to look for triangles...
Definition: trianglefromposquery.h:125
This class is a runtime container for Autodesk Navigation WorldElements such as NavData, Bots, BoxObstacles, TagVolumes...
Definition: world.h:52
NavTrianglePtr m_resultTrianglePtr
Updated during processing to store the nearest triangle found to m_inputPos3f.
Definition: trianglefromposquery.h:129
QueryType
Enumerates all the type of query.
Definition: iquery.h:25
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Indicates that the query has not yet been initialized.
Definition: iquery.h:295
Instructs the query to retrieve the first triangle above the point provided.
Definition: trianglefromposquery.h:39
TriangleFromPosQueryResult m_result
Updated during processing to indicate the result of the query.
Definition: trianglefromposquery.h:134
void SetQueryType(TriangleFromPosQueryType queryType)
Write accessor for m_queryType.
Definition: trianglefromposquery.inl:21
Instructs the query to retrieve the first triangle below the point provided.
Definition: trianglefromposquery.h:38
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:17
Indicates that the query has not yet been launched.
Definition: iquery.h:296
The TriangleFromPosQuery class takes a position in the 3D space (m_inputPos3f), and finds the nearest...
Definition: trianglefromposquery.h:46
Indicates that the point provided is outside the navigable boundaries of the NavMesh.
Definition: trianglefromposquery.h:28
TriangleFromPosQueryType
Enumerates the possible ways a TriangleFromPosQuery can choose the triangle it retrieves.
Definition: trianglefromposquery.h:35
void Initialize()
Should be called by the derived class prior to perform the query or to push it in a QueryQueue...
Definition: iquery.h:220
void PerformQuery(WorkingMemory *workingMemory=nullptr)
If workingMemory param is nullptr, m_database.GetWorkingMemory() will be used.
Definition: trianglefromposquery.cpp:78
Indicates that the query was completed successfully; a triangle was found.
Definition: trianglefromposquery.h:31
float KyFloat32
float
Definition: types.h:32
Indicates the query has not yet been launched.
Definition: trianglefromposquery.h:26
3d vector using 32bits floating points.
Definition: vec3f.h:16
Instructs the query to retrieve the nearest triangle to the point provided, regardless of whether it ...
Definition: trianglefromposquery.h:37