gwnavruntime/queries/trianglefromposquery.h Source File

trianglefromposquery.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: JUBA - secondary contact: NOBODY
9 #ifndef Navigation_TriangleFromPosQuery_H
10 #define Navigation_TriangleFromPosQuery_H
11 
12 
17 
18 
19 namespace Kaim
20 {
21 
22 class ActiveCell;
23 class NavCell;
24 class NavFloorBlob;
25 template <class T> class WorkingMemArray;
26 
27 
30 {
33 
36 
38 };
39 
42 {
46 };
47 
52 class TriangleFromPosQuery : public IAtomicQuery
53 {
54 public:
55  static QueryType GetStaticType() { return TypeTriangleFromPos; }
56  virtual QueryType GetType() const { return TypeTriangleFromPos; }
57  virtual void BuildQueryBlob(BaseBlobHandler* blobHandler);
58  virtual void InitFromQueryBlob(World* world, void* blob);
59  virtual Ptr<BaseBlobHandler> CreateQueryBlobHandler() { return CreateStaticQueryBlobHandler(); }
60  static Ptr<BaseBlobHandler> CreateStaticQueryBlobHandler();
61 
62  // ---------------------------------- Public Member Functions ----------------------------------
63 
65  virtual ~TriangleFromPosQuery() {}
66 
67  // ---------------------------------- Functions to set up the query ----------------------------------
68 
72  void BindToDatabase(Database* database);
73 
78  void Initialize(const Vec3f& pos);
79 
80  // ---------------------------------- write accessors for query parameters ----------------------------------
81 
84  void SetPositionSpatializationRange(const PositionSpatializationRange& positionSpatializationRange);
85 
88  void SetQueryType(TriangleFromPosQueryType queryType);
89 
90 
91  // ---------------------------------- Query framework functions ----------------------------------
92 
93  virtual void Advance(WorkingMemory* workingMemory);
94 
98  void PerformQuery(WorkingMemory* workingMemory = KY_NULL);
99 
100  // ---------------------------------- Accessors ----------------------------------
101 
102  TriangleFromPosQueryResult GetResult() const;
103  const Vec3f& GetInputPos() const;
104  const NavTrianglePtr& GetResultTrianglePtr() const;
105  TriangleFromPosQueryType GetQueryType() const;
106  KyFloat32 GetAltitudeOfProjectionInTriangle() const;
107 
108  const PositionSpatializationRange& GetPositionSpatializationRange() const;
109 
110 public: // internal
111  void SetInputIntegerPos(const WorldIntegerPos& integerPos);
112  const WorldIntegerPos& GetInputIntegerPos() const;
113  void PerformQueryWithInputCoordPos(WorkingMemory* workingMemory);
114 
115 private :
116  void SetResult(TriangleFromPosQueryResult result);
117  void GetNearestTrianglePtrFromPos(WorkingMemory* workingMemory);
118  KyResult FilterNavFloorsFromAltitudeRange(WorkingMemArray<NavFloor*>& floorIndicesToTest, ActiveCell& activeCell);
119  void ProcessFilteredNavFloors(const WorkingMemArray<NavFloor*>& filteredMetaFloorIndices,
120  const Vec3f& pos3fInCell, KyFloat32 multiplicatorValidyForQueryType);
121  void FindTriangleInFloor(const Vec3f& posInCell, NavFloor* navFloor, const NavFloorBlob* floorBlob,
122  bool& triangleFound, KyFloat32& minDist, KyFloat32 multiplicatorValidyForQueryType);
123 
124 private:
125  WorldIntegerPos m_inputIntegerPos;
126 
128 
129  PositionSpatializationRange m_positionSpatializationRange;
130 
135 
139 
142 
144 };
145 
146 }
147 
149 
150 
151 
152 #endif //Navigation_TriangleFromPosQuery_H
153 
void SetPositionSpatializationRange(const PositionSpatializationRange &positionSpatializationRange)
Write accessor for m_positionSpatializationRange.
Definition: trianglefromposquery.inl:18
Indicates the query has not yet been initialized.
Definition: trianglefromposquery.h:31
TriangleFromPosQueryResult
Enumerates the possible results of a TriangleFromPosQuery.
Definition: trianglefromposquery.h:29
void BindToDatabase(Database *database)
Binds the query with the specified Database, clears all the inputs and outputs and sets all other par...
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
This class is a runtime wrapper of a NavFloorBlob, it gathers all the runtime information associated ...
Definition: navfloor.h:40
The NavFloorBlob contains a connected and not overlapping part of triangle mesh static data within a ...
Definition: navfloorblob.h:42
Indicates that insufficient working memory caused the query to stop.
Definition: trianglefromposquery.h:35
virtual void Advance(WorkingMemory *workingMemory)
This function is called by the QueryQueue to process one step on the query.
Definition: trianglefromposquery.inl:12
KyFloat32 m_altitudeInTriangle
Updated during processing to indicate the projected altitude of m_inputPos3f on the triangle stored i...
Definition: trianglefromposquery.h:171
Vec3f m_inputPos3f
The position on the (X,Y) plane used to retrieve the nearest triangle.
Definition: trianglefromposquery.h:157
This object gathers all the active NavFloors at a CellPos.
Definition: activecell.h:23
PositionSpatializationRange m_positionSpatializationRange
The altitude tolerance around m_inputPos3f that will be searched for triangles.
Definition: trianglefromposquery.h:159
TriangleFromPosQueryType m_queryType
An element from the TriangleFromPosQueryType enumeration that indicates whether to look for triangles...
Definition: trianglefromposquery.h:164
#define KY_NULL
Null value.
Definition: types.h:247
void PerformQuery(WorkingMemory *workingMemory=0)
Performs the query.
This class is a runtime container for Gameware Navigation WorldElements such as NavData, Bots, BoxObstacles, TagVolumes...
Definition: world.h:54
NavTrianglePtr m_resultTrianglePtr
Updated during processing to store the nearest triangle found to m_inputPos3f.
Definition: trianglefromposquery.h:168
QueryType
Enumerates all the type of query.
Definition: iquery.h:29
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:64
Definition: gamekitcrowddispersion.h:20
Indicates that the query has not yet been initialized.
Definition: iquery.h:346
Instructs the query to retrieve the first triangle above the point provided.
Definition: trianglefromposquery.h:45
TriangleFromPosQueryResult m_result
Updated during processing to indicate the result of the query.
Definition: trianglefromposquery.h:173
void SetQueryType(TriangleFromPosQueryType queryType)
Write accessor for m_queryType.
Definition: trianglefromposquery.inl:23
Instructs the query to retrieve the first triangle below the point provided.
Definition: trianglefromposquery.h:44
Utilities for dealing with NavData coordinates, which are expressed in a world space based on integer...
Definition: worldintegerpos.h:21
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:22
Indicates that the query has not yet been launched.
Definition: iquery.h:347
The TriangleFromPosQuery class takes a position in the 3D space (m_inputPos3f), and finds the nearest...
Definition: trianglefromposquery.h:53
Indicates that the point provided is outside the navigable boundaries of the NavMesh.
Definition: trianglefromposquery.h:34
TriangleFromPosQueryType
Enumerates the possible ways a TriangleFromPosQuery can choose the triangle it retrieves.
Definition: trianglefromposquery.h:41
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
Indicates that the query was completed successfully; a triangle was found.
Definition: trianglefromposquery.h:37
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
Indicates the query has not yet been launched.
Definition: trianglefromposquery.h:32
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23
Instructs the query to retrieve the nearest triangle to the point provided, regardless of whether it ...
Definition: trianglefromposquery.h:43