gwnavruntime/queries/utils/queryutils.h Source File

queryutils.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_QueryUtils_H
10 #define Navigation_QueryUtils_H
11 
18 namespace Kaim
19 {
20 
21 class Box2f;
22 class NavTrianglePtr;
23 class NavTriangleRawPtr;
24 class NavHalfEdgePtr;
25 class NavHalfEdgeRawPtr;
26 class TriangleFromPosAndTriangleSeedQuery;
27 class ThinCapsuleWithExtentOffset;
28 
31 {
32  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
33 
34 public:
35  QueryUtils() : m_database(KY_NULL), m_workingMemory(KY_NULL), m_traverseLogicUserData(KY_NULL), m_performQueryStat(PerformQueryStat_Unspecified) {}
36  QueryUtils(Database* database, WorkingMemory* workingMemory, void* traverseLogicUserData);
37  void Init(Database* database, WorkingMemory* workingMemory, void* traverseLogicUserData);
38  void SetPerformQueryStat(PerformQueryStat performQueryStat);
39 
40  // ------------------------------ Accessors -----------------------------------
41  Database* GetDatabase() { return m_database; }
42  WorkingMemory* GetWorkingMemory() { return m_workingMemory; }
43  void* GetTraverseLogicUserData() { return m_traverseLogicUserData; }
44 
45  // ------------------------------ Location functions -----------------------------------
46 
54  bool FindTriangleFromPositionIfNotValid(NavTrianglePtr& navTrianglePtr, const Vec3f& pos, const PositionSpatializationRange& positionSpatializationRange);
55 
65  bool FindTriangleFromPositionIfNotValid(NavTrianglePtr& navTrianglePtr, const Vec3f& pos, const PositionSpatializationRange& positionSpatializationRange, WorldIntegerPos& outputIntegerPos);
66 
76  bool FindTriangleFromPositionIfNotValid(NavTrianglePtr& navTrianglePtr, const Vec3f& pos, const WorldIntegerPos& integerPos, const PositionSpatializationRange& positionSpatializationRange);
77 
78 
87  template<class TraverseLogic>
89 
90 
91 public : // internal
92  void GetNextHalfEdgeAroundStartVertex(const NavHalfEdgeRawPtr& currentHalfEdge, NavHalfEdgeRawPtr& nextHalfEdge); // Provides the next HalEdge (CW) starting from the provided HalEdge start vertex.
93  void GetPrevHalfEdgeAroundDestVertex(const NavHalfEdgeRawPtr& currentHalfEdge, NavHalfEdgeRawPtr& prevHalfEdge); // Provides the previous HalEdge (CCW) ending at the provided HalEdge end vertex.
94 
95  template<class TraverseLogic>
96  KyResult FindValidPositionFromIntegerIntersection(const Vec3f& collisionPos3f, const NavHalfEdgePtr& halfEdgePtrHit,
97  WorldIntegerPos& arrivalIntegerPos, NavTrianglePtr& arrivalTrianglePtr);
98 
99  template<class TLogic, class BorderHalfEdgeProcessor>
100  KyResult BrowseAndProcessAllBorderNavHalfEdgeInBox(BorderHalfEdgeProcessor& borderHalfEdgeProcessor);
101 
102 private :
103  class CheckIfCurrentIntegerPositionIsValidParam
104  {
105  public:
106  CoordPos64 m_start;
107  CoordPos64 m_end;
108  CoordPos64 m_third;
109  CoordPos64 m_startToEnd;
110  CoordPos64 m_endToThird;
111  CoordPos64 m_thirdTostart;
112  WorldIntegerPos m_currentArrivalIntegerPos;
113  };
114 
115  template<class TraverseLogic>
116  KyResult CheckIfCurrentIntegerPositionIsValid(const CheckIfCurrentIntegerPositionIsValidParam& params,
117  TriangleFromPosAndTriangleSeedQuery& triangleFromPosAndTriangleSeedQuery, WorldIntegerPos& arrivalIntegerPos, NavTrianglePtr& arrivalTrianglePtr);
118 
119 public:
121  WorkingMemory* m_workingMemory;
122  void* m_traverseLogicUserData;
123  PerformQueryStat m_performQueryStat;
124 };
125 
129 {
130 public:
131  ThinCapsuleWithExtentOffset(const CoordPos64& capsuleStartCoordPos, const CoordPos64& capsuleEndCoordPos,
132  KyUInt64 capsuleSquareRadius, KyUInt32 recoveryDistance)
133  {
134  m_capsuleStartCoordPos = capsuleStartCoordPos;
135  m_capsuleEndCoordPos = capsuleEndCoordPos;
136  m_capsuleSquareRadius = capsuleSquareRadius;
137  m_recoveryDistance = recoveryDistance;
138 
139  CoordPos64 capsule = m_capsuleEndCoordPos - m_capsuleStartCoordPos;
140  m_capsuleSquareLength = capsule.GetSquareLength();
141  // m_offset will be computed lazily (only if needed)
142  m_offset.x = KyInt64MAXVAL;
143  }
144 
145  CoordPos64 GetOffset();
146 
147 public:
149  CoordPos64 m_capsuleEndCoordPos;
150  KyUInt64 m_capsuleSquareRadius;
151  KyUInt32 m_recoveryDistance;
152 
153  KyUInt64 m_capsuleSquareLength;
154 
155 private:
156  CoordPos64 m_offset;
157 };
158 
159 
160 
161 
162 }
163 
166 #endif //Navigation_QueryUtils_H
167 
KyInt64 x
The size of the vector along the X axis.
Definition: vec2ll.h:175
CoordPos64 m_capsuleStartCoordPos
lazily compute the offset and returns it
Definition: queryutils.h:165
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
#define KY_NULL
Null value.
Definition: types.h:247
This class defines a two-dimensional vector whose coordinates are stored using 64-bit integers...
Definition: vec2ll.h:27
bool IsHalfEdgeCompatibleWithThinCapsule(const NavHalfEdgeRawPtr &halfEdge, ThinCapsuleWithExtentOffset &capsuleParams)
Check if the specified half edge intersects the specified thin capsule.
Definition: queryutils.inl:25
bool FindTriangleFromPositionIfNotValid(NavTrianglePtr &navTrianglePtr, const Vec3f &pos, const PositionSpatializationRange &positionSpatializationRange)
Checks the validity of the specified triangle.
Database * m_database
The Database taken into account by queries made through this object. Do not modify.
Definition: queryutils.h:134
unsigned __int64 KyUInt64
Type used internally to represent an unsigned 64-bit integer.
Definition: types.h:38
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:64
The TriangleFromPosAndTriangleSeedQuery class finds the nearest triangle in the NavMesh that covers t...
Definition: trianglefromposandtriangleseedquery.h:47
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
WorkingMemory * m_workingMemory
Contains memory buffers used for performing queries and storing results. For internal use...
Definition: queryutils.h:135
Utilities for dealing with NavData coordinates, which are expressed in a world space based on integer...
Definition: worldintegerpos.h:21
PerformQueryStat
Definition: iquery.h:66
This class is an helper used internally by the Queries to factorize Code that is used in many Queries...
Definition: queryutils.h:30
KyInt64 GetSquareLength() const
Returns the square of the magnitude of the vector.
Definition: vec2ll.h:145
Each instance of this class uniquely identifies a single NavHalfEdge in a NavFloor.
Definition: navhalfedgeptr.h:19
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
#define KyInt64MAXVAL
The maximum value that can be stored in the KyInt64 variable type.
Definition: types.h:234
Particuliar class used to represent the ThinCapsule for QueryUtils::IsHalfEdgeCompatibleWithThinCapsu...
Definition: queryutils.h:143
Each instance of this class uniquely identifies a singleNavHalfEdge in a NavFloor.
Definition: navhalfedgerawptr.h:34
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23