gwnavruntime/path/path.h Source File

path.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: GUAL - secondary contact: NOBODY
9 
10 #ifndef Navigation_Path_H
11 #define Navigation_Path_H
12 
18 
19 
20 namespace Kaim
21 {
22 class DatabaseGenMetrics;
23 class ChannelArray;
24 
27 {
37  PathEdgeType_MaxCount,
38 };
39 
40 
42 class Path
43 {
44  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Path)
46  Path();
47  ~Path();
48 
49 public:
51  class CreateConfig
52  {
53  public:
54  // ---------------------------------- Public Members ----------------------------------
55  CreateConfig(KyUInt32 nodesCount = 0) : m_nodesCount(nodesCount) {}
56 
57  KyUInt32 m_nodesCount;
58  };
59 
60 
61  // ---------------------------------- Path Creation ----------------------------------
62 
65  static Ptr<Path> CreatePath(const CreateConfig& createConfig);
66 
67  void SetNavigationProfileId(KyUInt32 navigationProfileId);
68  KyUInt32 GetNavigationProfileId() const;
69 
70  // ---------------------------------- Get Counts ----------------------------------
71 
72  KyUInt32 GetNodeCount() const;
73  KyUInt32 GetEdgeCount() const;
74 
75  // ---------------------------------- Get Cost and Distance ----------------------------------
76 
79  KyFloat32 GetPathDistance() const;
80 
83  KyFloat32 GetPathCost() const;
84 
85  // ---------------------------------- Get Node Data ----------------------------------
86 
87  const Vec3f& GetPathStartPosition() const;
88  const Vec3f& GetPathEndPosition() const;
89 
90  const Vec3f* GetNodePositionBuffer() const;
91  const Vec3f& GetNodePosition(KyUInt32 nodeIdx) const;
92  Vec3f& GetNodePosition(KyUInt32 nodeIdx);
93 
94  const WorldIntegerPos* GetNodeIntegerPositionBuffer() const;
95  const WorldIntegerPos& GetNodeIntegerPosition(KyUInt32 nodeIdx) const;
96  WorldIntegerPos& GetNodeIntegerPosition(KyUInt32 nodeIdx);
97 
98  const NavTrianglePtr& GetNodeNavTrianglePtr(KyUInt32 nodeIdx) const;
99  NavTrianglePtr& GetNodeNavTrianglePtr(KyUInt32 nodeIdx);
100 
101  const NavGraphVertexPtr& GetNodeNavGraphVertexPtr(KyUInt32 nodeIdx) const;
102  NavGraphVertexPtr& GetNodeNavGraphVertexPtr(KyUInt32 nodeIdx);
103 
104  // ---------------------------------- Get Edge Data ----------------------------------
105 
106  const Vec3f& GetPathEdgeStartPosition(KyUInt32 edgeIdx) const;
107  const Vec3f& GetPathEdgeEndPosition (KyUInt32 edgeIdx) const;
108 
109  const NavTrianglePtr& GetPathEdgeStartNavTrianglePtr(KyUInt32 edgeIdx) const;
110  const NavTrianglePtr& GetPathEdgeEndNavTrianglePtr (KyUInt32 edgeIdx) const;
111 
112  const NavGraphEdgePtr& GetEdgeNavGraphEdgePtr(KyUInt32 edgeIdx) const;
113  NavGraphEdgePtr& GetEdgeNavGraphEdgePtr(KyUInt32 edgeIdx);
114 
115  PathEdgeType GetPathEdgeType(KyUInt32 edgeIdx) const;
116 
117  // ---------------------------------- Set Node Data ----------------------------------
118 
119  void SetNodePosition (KyUInt32 nodeIdx, const Vec3f& position );
120  void SetNodeIntegerPosition (KyUInt32 nodeIdx, const WorldIntegerPos& integerPos );
121  void SetNodeNavTrianglePtr (KyUInt32 nodeIdx, const NavTrianglePtr& navTrianglePtr );
122  void SetNodeNavGraphVertexPtr(KyUInt32 nodeIdx, const NavGraphVertexPtr& navGraphVertexPtr);
123 
124  void SetNodePosition3fAndInteger(KyUInt32 nodeIdx, const Vec3f& position, const WorldIntegerPos& integerPos);
125  // ---------------------------------- Set Edge Data ----------------------------------
126 
127  void SetEdgeNavGraphEdgePtr(KyUInt32 edgeIdx, const NavGraphEdgePtr& navGraphEdgePtr);
128  void SetPathEdgeType (KyUInt32 edgeIdx, PathEdgeType edgeType );
129 
130  void SetPathCostAndDistance(KyFloat32 pathCost, KyFloat32 pathDistance);
131 
132  const CellBox& GetPathCellBox() const;
133  CellBox& GetPathCellBox();
134  void SetPathCellBox(const CellBox& cellBox);
135 
136  void ComputeAllNodeIntegerPositionAndPathCellBox(const DatabaseGenMetrics& genMetrics);
137 
138  KyUInt32 GetByteSize() const;
139 private :
140  static KyUInt32 ComputeByteSize(const CreateConfig& createConfig);
141 
142  void InitBuffers();
143  void ClearAllBeforeDestruction();
144 
145  template <class T>
146  void ClearBufferCPP(T*& buffer, KyUInt32 count);
147  template <class T>
148  void ClearBufferPOD(T*& buffer, KyUInt32 count);
149  template <class T>
150  void InitBufferCPP(T*& buffer, KyUInt32 count, char*& memory);
151  template <class T>
152  void InitBufferPOD(T*& buffer, KyUInt32 count, char*& memory);
153 
154 
155 public:
156  // ---------------------------------- Public Data Members ----------------------------------
157 
162 
164  Ptr<ChannelArray> m_channelArray;
165 
166 
167 private:
168  KyUInt32 m_navigationProfileId;
169 
170  KyUInt32 m_byteSize;
171 
172  KyUInt32 m_nodesCount;
173  KyUInt32 m_edgesCount;
174 
175  KyFloat32 m_pathDistance;
176  KyFloat32 m_pathCost;
177 
178  CellBox m_pathCellBox;
179 
180  Vec3f* m_nodePositions;
181  WorldIntegerPos* m_nodeIntegerPositions;
182  NavTrianglePtr* m_nodeTrianglePtrs;
183  NavGraphVertexPtr* m_nodeGraphVertexPtrs;
184 
185  NavGraphEdgePtr* m_edgeNavGraphEdgePtr;
186  KyUInt8* m_edgeTypes;
187 
188  KyUInt32 RefCount; // consider thread-safetyness here with mutable AtomicInt<int> RefCount;
189 
190 public: // internal
191  // Lifetime - separate implementation due to Create function
192  void AddRef();
193  void Release();
194  // Debug method only.
195  int GetRefCount() const { return RefCount; }
196 };
197 
198 
199 }
200 
202 
203 
205 #endif
This class represents a two-dimensional axis-aligned bounding box whose dimensions are stored using 3...
Definition: box2i.h:119
A class that configures the creation of a Path.
Definition: path.h:52
The PathEdge corresponds to a NavGraph edge.
Definition: path.h:30
The PathEdge is going along an a NavGraphEdge but not starting nor ending at one of the NavGrapHVerte...
Definition: path.h:35
Database * m_database
The Database on which the Path has been computed.
Definition: path.h:201
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
The PathEdge is going from the NavMesh to outside.
Definition: path.h:34
The PathEdgeType has not yet been set for the corresponding PathEdge.
Definition: path.h:28
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:64
unsigned char KyUInt8
Type used internally to represent an unsigned 8-bit integer.
Definition: types.h:41
Definition: gamekitcrowddispersion.h:20
Each instance of this class uniquely identifies a single NavGraphVertex in a NavGraph.
Definition: navgraphvertexptr.h:22
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
The PathEdge is going from the NavMesh to outside.
Definition: path.h:32
Utilities for dealing with NavData coordinates, which are expressed in a world space based on integer...
Definition: worldintegerpos.h:21
PathEdgeType
Defines the different kind of PathEdge within a Path.
Definition: path.h:26
The PathEdge has been computed on the NavMesh.
Definition: path.h:29
KyFloat32 GetPathCost() const
Retrieves the total sum of the cost calculated for each segment of the path by a RayCanGoQuery.
Definition: path.inl:45
The PathEdge is coming from outside to the NavMesh.
Definition: path.h:31
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:22
The PathEdge is coming from outside to the NavMesh.
Definition: path.h:33
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Ptr< ChannelArray > m_channelArray
The ChannelArray maintaining Channels around the path sections laying on the NavMesh.
Definition: path.h:204
KyFloat32 GetPathDistance() const
Retrieves the total sum of the distance covered by each segment of the path.
Definition: path.inl:44
Each instance of this class uniquely identifies a single and mono-directionnal NavGraphEdge in a NavG...
Definition: navgraphedgeptr.h:25
The PathEdge is fro an abstract Path.
Definition: path.h:36
static Ptr< Path > CreatePath(const CreateConfig &createConfig)
Creates a Path instance and allocates necessary memory accordingly to the information provided throug...
This class gathers a set of generation parameters of one Database and manages the conversion between ...
Definition: databasegenmetrics.h:24
The class representing a path.
Definition: path.h:42
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