gwnavruntime/navmesh/identifiers/navhalfedgeptr.h Source File

navhalfedgeptr.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 // ---------- Primary contact: JUBA - secondary contact: NOBODY
8 #ifndef Navigation_NavHalfEdgePtr_H
9 #define Navigation_NavHalfEdgePtr_H
10 
12 
13 namespace Kaim
14 {
15 
18 class NavHalfEdgePtr
19 {
20  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
21 public:
22  NavHalfEdgePtr();
23 
27  NavHalfEdgePtr(const NavFloorPtr& navFloorPtr, NavHalfEdgeIdx halfEdgeIdx);
28 
30  explicit NavHalfEdgePtr(const NavHalfEdgeRawPtr& navHalfEdgeRawPtr);
31 
35  void Set(const NavFloorPtr& navFloorPtr, NavHalfEdgeIdx halfEdgeIdx);
36 
38  bool IsValid() const;
39 
40  void Invalidate();
41 
42  bool operator==(const NavHalfEdgePtr& rhs) const;
43  bool operator!=(const NavHalfEdgePtr& rhs) const;
44 
46  NavFloor* GetNavFloor() const;
47  const NavFloorBlob* GetNavFloorBlob() const;
48 
49 
50  // ---------------------------------- Member Functions for valid instance ----------------------------------
53 
57 
60  const NavFloorBlob* GetNavFloorBlob_Unsafe() const;
61 
65 
69  const CellPos& GetCellPos() const;
70 
73  const NavTag& GetNavTag() const;
74 
80  void GetTriangleVerticesPos3f(Vec3f& v0Pos3f, Vec3f& v1Pos3f, Vec3f& v2Pos3f) const;
81 
86  void GetVerticesPos3f(Vec3f& v0Pos3f, Vec3f& v1Pos3f) const;
87 
90  Vec3f GetStartVertexPos3f() const;
91 
94  Vec3f GetEndVertexPos3f() const;
95 
99 
103 
107 
111 
115 
119 
123  template <class TraverseLogic>
124  bool IsHalfEdgeCrossable(void* traverseLogicUserData) const;
125 
129  bool IsHalfEdgeCrossable() const;
130 
136  template <class TraverseLogic>
137  bool IsHalfEdgeCrossable(NavHalfEdgePtr& resultPtr, void* traverseLogicUserData) const;
138 
143  bool IsHalfEdgeCrossable(NavHalfEdgePtr& resultPtr) const;
144 
148  void GetPairHalfEdgePtr(NavHalfEdgePtr& resultPtr) const;
149 
152  void GetNextHalfEdgePtr(NavHalfEdgePtr& resultPtr) const;
153 
156  void GetPrevHalfEdgePtr(NavHalfEdgePtr& resultPtr) const;
157 
164  template<class TraverseLogic>
165  NavHalfEdgePtr GetNextNavHalfEdgePtrAlongBorder(void* traverseLogicUserData) const;
166 
173  template<class TraverseLogic>
174  NavHalfEdgePtr GetPrevNavHalfEdgePtrAlongBorder(void* traverseLogicUserData) const;
175 
176 public:
178  CompactNavHalfEdgeIdx m_halfEdgeIdx;
179 };
180 
181 KY_INLINE NavHalfEdgePtr::NavHalfEdgePtr() : m_halfEdgeIdx(CompactNavHalfEdgeIdx_MAXVAL) {}
182 
183 KY_INLINE NavHalfEdgePtr::NavHalfEdgePtr(const NavFloorPtr& navFloorPtr, NavHalfEdgeIdx halfEdgeIdx) :
184  m_navFloorPtr(navFloorPtr), m_halfEdgeIdx((CompactNavHalfEdgeIdx)halfEdgeIdx) {}
186 KY_INLINE NavHalfEdgePtr::NavHalfEdgePtr(const NavHalfEdgeRawPtr& navHalfEdgeRawPtr) :
187  m_navFloorPtr(navHalfEdgeRawPtr.GetNavFloor()), m_halfEdgeIdx(navHalfEdgeRawPtr.m_halfEdgeIdx) {}
189 KY_INLINE void NavHalfEdgePtr::Set(const NavFloorPtr& navFloorPtr, NavHalfEdgeIdx halfEdgeIdx)
190 {
191  m_navFloorPtr = navFloorPtr;
192  m_halfEdgeIdx = (CompactNavHalfEdgeIdx)halfEdgeIdx;
193 }
194 
195 KY_INLINE bool NavHalfEdgePtr::IsValid() const { return m_navFloorPtr.IsValid() && m_halfEdgeIdx != CompactNavHalfEdgeIdx_MAXVAL; }
197 KY_INLINE void NavHalfEdgePtr::Invalidate() { m_navFloorPtr.Invalidate(); m_halfEdgeIdx = CompactNavHalfEdgeIdx_MAXVAL; }
198 
199 KY_INLINE bool NavHalfEdgePtr::operator==(const NavHalfEdgePtr& rhs) const { return m_navFloorPtr == rhs.m_navFloorPtr && m_halfEdgeIdx == rhs.m_halfEdgeIdx; }
200 KY_INLINE bool NavHalfEdgePtr::operator!=(const NavHalfEdgePtr& rhs) const { return !(*this == rhs); }
201 
203 
205 KY_INLINE const NavFloorBlob* NavHalfEdgePtr::GetNavFloorBlob() const { return m_navFloorPtr.GetNavFloorBlob(); }
208 
210 
211 KY_INLINE const CellPos& NavHalfEdgePtr::GetCellPos() const { return GetRawPtr().GetCellPos(); }
212 KY_INLINE const NavTag& NavHalfEdgePtr::GetNavTag() const { return GetRawPtr().GetNavTag(); }
223 KY_INLINE void NavHalfEdgePtr::GetTriangleVerticesPos3f(Vec3f& v0Pos3f, Vec3f& v1Pos3f, Vec3f& v2Pos3f) const
224 {
225  return GetRawPtr().GetTriangleVerticesPos3f(v0Pos3f, v1Pos3f, v2Pos3f);
226 }
227 KY_INLINE void NavHalfEdgePtr::GetVerticesPos3f(Vec3f& v0Pos3f, Vec3f& v1Pos3f) const
228 {
229  return GetRawPtr().GetVerticesPos3f(v0Pos3f, v1Pos3f);
230 }
231 template<class TraverseLogic>
232 KY_INLINE bool NavHalfEdgePtr::IsHalfEdgeCrossable(void* traverseLogicUserData) const
233 {
234  return GetRawPtr().IsHalfEdgeCrossable<TraverseLogic>(traverseLogicUserData);
235 }
236 
237 template<class TraverseLogic>
238 KY_INLINE NavHalfEdgePtr NavHalfEdgePtr::GetNextNavHalfEdgePtrAlongBorder(void* traverseLogicUserData) const
239 {
240  return NavHalfEdgePtr(GetRawPtr().GetNextNavHalfEdgeRawPtrAlongBorder<TraverseLogic>(traverseLogicUserData));
241 }
242 
243 template<class TraverseLogic>
244 KY_INLINE NavHalfEdgePtr NavHalfEdgePtr::GetPrevNavHalfEdgePtrAlongBorder(void* traverseLogicUserData) const
245 {
246  return NavHalfEdgePtr(GetRawPtr().GetPrevNavHalfEdgeRawPtrAlongBorder<TraverseLogic>(traverseLogicUserData));
247 }
248 
249 inline bool NavHalfEdgePtr::IsHalfEdgeCrossable(NavHalfEdgePtr& resultPtr) const
250 {
251  NavHalfEdgeRawPtr resultRawPtr;
252  bool storeResult = GetRawPtr().IsHalfEdgeCrossable(resultRawPtr);
253  resultPtr = NavHalfEdgePtr(resultRawPtr);
254  return storeResult;
255 }
257 inline void NavHalfEdgePtr::GetPairHalfEdgePtr(NavHalfEdgePtr& resultPtr) const
258 {
259  NavHalfEdgeRawPtr resultRawPtr;
260  GetRawPtr().GetPairHalfEdgeRawPtr(resultRawPtr);
261  resultPtr = NavHalfEdgePtr(resultRawPtr);
262 }
263 
265 {
266  NavHalfEdgeRawPtr resultRawPtr;
267  GetRawPtr().GetNextHalfEdgeRawPtr(resultRawPtr);
268  resultPtr = NavHalfEdgePtr(resultRawPtr);
269 }
270 
272 {
273  NavHalfEdgeRawPtr resultRawPtr;
274  GetRawPtr().GetPrevHalfEdgeRawPtr(resultRawPtr);
275  resultPtr = NavHalfEdgePtr(resultRawPtr);
276 }
277 
278 template<class TraverseLogic>
279 inline bool NavHalfEdgePtr::IsHalfEdgeCrossable(NavHalfEdgePtr& resultPtr, void* traverseLogicUserData) const
280 {
281  NavHalfEdgeRawPtr resultRawPtr;
282  bool storeResult = GetRawPtr().IsHalfEdgeCrossable<TraverseLogic>(resultRawPtr, traverseLogicUserData);
283  resultPtr = NavHalfEdgePtr(resultRawPtr);
284  return storeResult;
285 }
287 
288 
289 }
290 #endif //Navigation_NavHalfEdgePtr_H
291 
NavFloor * GetNavFloor() const
Returns a pointer to the NavFloor identified by this object. Returns KY_NULL if this object is not va...
Definition: navfloorptr.h:97
bool operator!=(const NavHalfEdgePtr &rhs) const
Returns true if this object identifies a different edge from rhs.
Definition: navhalfedgeptr.h:207
Vec3f GetStartVertexPos3f() const
Returns the coordinates of the starting vertex of this NavHalfEdge.
Vec3f GetEndVertexPos3f() const
Returns the coordinates of the ending vertex of this NavHalfEdge.
Definition: navhalfedgeptr.h:221
bool IsHalfEdgeCrossable() const
Returns true if this edge is not on an external boundary of the NavMesh and not a internal edge that ...
Definition: navhalfedgeptr.h:228
NavHalfEdgeIdx GetHalfEdgeIdx() const
Returns the index of this edge within its NavFloor.
Definition: navhalfedgeptr.h:209
Each instance of this class uniquely identifies a single NavFloor.
Definition: navfloorptr.h:21
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
void Set(const NavFloorPtr &navFloorPtr, NavHalfEdgeIdx halfEdgeIdx)
Clears all information maintained by this object.
Definition: navhalfedgeptr.h:196
const CellPos & GetCellPos() const
Returns a const reference to the CellPos that indicates the position of the cell that contains this e...
Definition: navhalfedgeptr.h:218
KyFloat32 GetEndVertexAltitude() const
Returns the altitude (z coordinate) of the ending vertex of this NavHalfEdge.
Definition: navhalfedgeptr.h:225
Vec3f GetStartVertexPos3f() const
Returns the coordinates of the starting vertex of this NavHalfEdge.
Definition: navhalfedgeptr.h:220
const NavTag & GetNavTag() const
Retrieves the NavTag associated to the NavFloor that contains this halfEdge.
Definition: navhalfedgerawptr.inl:62
void GetVerticesPos3f(Vec3f &v0Pos3f, Vec3f &v1Pos3f) const
Updates the parameters to identify the start and end vertices of the specified edge.
Definition: navhalfedgeptr.h:234
const NavFloorBlob * GetNavFloorBlob() const
Returns a const pointer to the NavFloorBlob that contains this edge. Returns KY_NULL if this object i...
Definition: navhalfedgeptr.h:212
void GetPrevHalfEdgeRawPtr(NavHalfEdgeRawPtr &resultRawPtr) const
Updates resultRawPtr to identify the previous edge in the triangle.
Definition: navhalfedgerawptr.inl:55
NavFloor * GetNavFloor_Unsafe() const
Returns a pointer to the NavFloor identified by this object.
Definition: navfloorptr.h:100
void GetNextHalfEdgeRawPtr(NavHalfEdgeRawPtr &resultRawPtr) const
Updates resultRawPtr to identify the next edge in the triangle.
Definition: navhalfedgerawptr.inl:54
void GetPrevHalfEdgePtr(NavHalfEdgePtr &resultPtr) const
Updates resultPtr to identify the previous edge in the triangle.
Definition: navhalfedgeptr.h:278
KyUInt32 NavHalfEdgeIdx
An index that uniquely identifies a single edge of a triangle within the set of edges owned by a NavF...
Definition: navmeshtypes.h:87
KyFloat32 GetStartVertexAltitude() const
Returns the altitude (z coordinate) of the starting vertex of this NavHalfEdge.
Definition: navhalfedgerawptr.inl:64
CompactNavHalfEdgeIdx m_halfEdgeIdx
The index of this edge within its NavFloor.
Definition: navhalfedgeptr.h:185
NavFloor * GetNavFloor() const
Returns a pointer to the NavFloor that contains this edge. Returns KY_NULL if this object is not vali...
Definition: navhalfedgeptr.h:211
CoordPos GetEndVertexCoordPosInCell() const
Returns the 2D integer coordinates of the ending vertex of this edge in its NavCell.
Definition: navhalfedgeptr.h:227
CoordPos GetStartVertexCoordPosInCell() const
Returns the 2D integer coordinates of the starting vertex of this edge in its NavCell.
Definition: navhalfedgerawptr.inl:51
void GetTriangleVerticesPos3f(Vec3f &v0Pos3f, Vec3f &v1Pos3f, Vec3f &v2Pos3f) const
Updates the parameters to identify the vertices in the specified triangle.
Definition: navhalfedgeptr.h:230
bool IsValid() const
Returns true if this object refers to a valid NavFloor, which means a NavFloor:that exists...
Definition: navfloorptr.h:83
const NavTag & GetNavTag() const
Retrieves the NavTag associated to the NavFloor that contains this halfEdge.
Definition: navhalfedgeptr.h:219
CoordPos64 GetStartVertexCoordPos64() const
Returns the x,y integer coordinates of the starting vertex of this NavHalfEdge.
Definition: navhalfedgeptr.h:222
NavHalfEdgePtr GetNextNavHalfEdgePtrAlongBorder(void *traverseLogicUserData) const
Returns the next edge along the border of the NavMesh according to TraverseLogic. ...
Definition: navhalfedgeptr.h:245
This class defines a two-dimensional vector whose coordinates are stored using 64-bit integers...
Definition: vec2ll.h:27
NavFloorPtr m_navFloorPtr
The NavFloor that contains this edge.
Definition: navhalfedgeptr.h:184
void GetVerticesPos3f(Vec3f &v0Pos3f, Vec3f &v1Pos3f) const
Updates the parameters to identify the start and end vertices of the specified edge.
const CellPos & GetCellPos() const
Returns a const reference to the CellPos that indicates the position of the cell that contains this e...
Definition: navhalfedgerawptr.inl:60
const NavFloorBlob * GetNavFloorBlob() const
Returns a const pointer to the NavFloorBlob identified by this object. Returns KY_NULL if this object...
Definition: navfloorptr.h:98
const NavFloorBlob * GetNavFloorBlob_Unsafe() const
Returns a const pointer to the NavFloorBlob identified by this object.
Definition: navfloorptr.h:101
CoordPos64 GetEndVertexCoordPos64() const
Returns the x,y integer coordinates of the ending vertex of this NavHalfEdge.
NavFloorRawPtr GetRawPtr() const
Constructs and returns a NavFloorRawPtr that refers to the same NavFloor.
Definition: navfloorptr.h:103
CoordPos GetStartVertexCoordPosInCell() const
Returns the 2D integer coordinates of the starting vertex of this edge in its NavCell.
Definition: navhalfedgeptr.h:226
CoordPos64 GetEndVertexCoordPos64() const
Returns the x,y integer coordinates of the ending vertex of this NavHalfEdge.
Definition: navhalfedgeptr.h:223
NavHalfEdgePtr()
Creates an invalid NavHalfEdgePtr.
Definition: navhalfedgeptr.h:188
Vec3f GetEndVertexPos3f() const
Returns the coordinates of the ending vertex of this NavHalfEdge.
This class defines a two-dimensional vector whose coordinates are stored using 32-bit integers...
Definition: vec2i.h:26
Definition: gamekitcrowddispersion.h:20
bool IsValid() const
Returns true if this object refers to a valid edge: i.e. an edge in a valid NavFloor. see NavFloorPtr::IsValid()
Definition: navhalfedgeptr.h:202
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
CoordPos GetEndVertexCoordPosInCell() const
Returns the 2D integer coordinates of the ending vertex of this edge in its NavCell.
Definition: navhalfedgerawptr.inl:52
void GetPairHalfEdgeRawPtr(NavHalfEdgeRawPtr &resultRawPtr) const
Updates resultRawPtr to identify the edge in the next adjacent triangle that borders this edge...
const NavFloorBlob * GetNavFloorBlob_Unsafe() const
Returns a const pointer to the NavFloorBlob that contains this edge.
Definition: navhalfedgeptr.h:214
NavFloor * GetNavFloor_Unsafe() const
Returns a pointer to the NavFloor that contains this edge.
Definition: navhalfedgeptr.h:213
NavHalfEdgeRawPtr GetRawPtr() const
Constructs and returns a NavHalfEdgeRawPtr that refers to the same NavHalfEdge.
Definition: navhalfedgeptr.h:216
KyFloat32 GetEndVertexAltitude() const
Returns the altitude (z coordinate) of the ending vertex of this NavHalfEdge.
Definition: navhalfedgerawptr.inl:69
void Invalidate()
Invalidates this object.
Definition: navhalfedgeptr.h:204
void GetTriangleVerticesPos3f(Vec3f &v0Pos3f, Vec3f &v1Pos3f, Vec3f &v2Pos3f) const
Updates the parameters to identify the vertices in the specified triangle.
void GetPairHalfEdgePtr(NavHalfEdgePtr &resultPtr) const
Updates resultPtr to identify the edge in the next adjacent triangle that borders this edge...
Definition: navhalfedgeptr.h:264
NavHalfEdgePtr GetPrevNavHalfEdgePtrAlongBorder(void *traverseLogicUserData) const
Returns the previous edge along the border of the NavMesh according to TraverseLogic.
Definition: navhalfedgeptr.h:251
void Invalidate()
Invalidates this object.
Definition: navfloorptr.h:82
Each instance of this class uniquely identifies a single NavHalfEdge in a NavFloor.
Definition: navhalfedgeptr.h:19
void GetNextHalfEdgePtr(NavHalfEdgePtr &resultPtr) const
Updates resultPtr to identify the next edge in the triangle.
Definition: navhalfedgeptr.h:271
bool IsHalfEdgeCrossable(void *traverseLogicUserData) const
Returns true if this edge can be traversed according the TraverseLogic.
Definition: navhalfedgerawptr.inl:76
KyFloat32 GetStartVertexAltitude() const
Returns the altitude (z coordinate) of the starting vertex of this NavHalfEdge.
Definition: navhalfedgeptr.h:224
bool operator==(const NavHalfEdgePtr &rhs) const
Returns true if this object identifies the same edge as rhs, or if both are invalid.
Definition: navhalfedgeptr.h:206
CoordPos64 GetStartVertexCoordPos64() const
Returns the x,y integer coordinates of the starting vertex of this NavHalfEdge.
Each instance of this class uniquely identifies a singleNavHalfEdge in a NavFloor.
Definition: navhalfedgerawptr.h:34
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