gwnavruntime/navmesh/identifiers/navhalfedgeptr.h Source File

navhalfedgeptr.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 
10 
11 namespace Kaim
12 {
13 
17 {
18  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
19 public:
20  NavHalfEdgePtr();
21 
25  NavHalfEdgePtr(const NavFloorPtr& navFloorPtr, NavHalfEdgeIdx halfEdgeIdx);
26 
28  explicit NavHalfEdgePtr(const NavHalfEdgeRawPtr& navHalfEdgeRawPtr);
29 
33  void Set(const NavFloorPtr& navFloorPtr, NavHalfEdgeIdx halfEdgeIdx);
34 
36  bool IsValid() const;
37 
38  void Invalidate();
39 
40  bool operator==(const NavHalfEdgePtr& rhs) const;
41  bool operator!=(const NavHalfEdgePtr& rhs) const;
42 
44  NavFloor* GetNavFloor() const;
45  const NavFloorBlob* GetNavFloorBlob() const;
46 
47 
48  // ---------------------------------- Member Functions for valid instance ----------------------------------
51 
55 
58  const NavFloorBlob* GetNavFloorBlob_Unsafe() const;
59 
63 
67  const CellPos& GetCellPos() const;
68 
71  const NavTag& GetNavTag() const;
72 
78  void GetTriangleVerticesPos3f(Vec3f& v0Pos3f, Vec3f& v1Pos3f, Vec3f& v2Pos3f) const;
79 
84  void GetVerticesPos3f(Vec3f& v0Pos3f, Vec3f& v1Pos3f) const;
85 
88  Vec3f GetStartVertexPos3f() const;
89 
92  Vec3f GetEndVertexPos3f() const;
93 
97 
101 
105 
109 
113 
117 
121  template <class TraverseLogic>
122  bool IsHalfEdgeCrossable(void* traverseLogicUserData) const;
123 
127  bool IsHalfEdgeCrossable() const;
128 
134  template <class TraverseLogic>
135  bool IsHalfEdgeCrossable(NavHalfEdgePtr& resultPtr, void* traverseLogicUserData) const;
136 
141  bool IsHalfEdgeCrossable(NavHalfEdgePtr& resultPtr) const;
142 
146  void GetPairHalfEdgePtr(NavHalfEdgePtr& resultPtr) const;
147 
150  void GetNextHalfEdgePtr(NavHalfEdgePtr& resultPtr) const;
151 
154  void GetPrevHalfEdgePtr(NavHalfEdgePtr& resultPtr) const;
155 
162  template<class TraverseLogic>
163  NavHalfEdgePtr GetNextNavHalfEdgePtrAlongBorder(void* traverseLogicUserData) const;
164 
171  template<class TraverseLogic>
172  NavHalfEdgePtr GetPrevNavHalfEdgePtrAlongBorder(void* traverseLogicUserData) const;
173 
174 public:
176  CompactNavHalfEdgeIdx m_halfEdgeIdx;
177 };
178 
179 KY_INLINE NavHalfEdgePtr::NavHalfEdgePtr() : m_halfEdgeIdx(CompactNavHalfEdgeIdx_MAXVAL) {}
180 
181 KY_INLINE NavHalfEdgePtr::NavHalfEdgePtr(const NavFloorPtr& navFloorPtr, NavHalfEdgeIdx halfEdgeIdx) :
182  m_navFloorPtr(navFloorPtr), m_halfEdgeIdx((CompactNavHalfEdgeIdx)halfEdgeIdx) {}
183 
184 KY_INLINE NavHalfEdgePtr::NavHalfEdgePtr(const NavHalfEdgeRawPtr& navHalfEdgeRawPtr) :
185  m_navFloorPtr(navHalfEdgeRawPtr.GetNavFloor()), m_halfEdgeIdx(navHalfEdgeRawPtr.m_halfEdgeIdx) {}
186 
187 KY_INLINE void NavHalfEdgePtr::Set(const NavFloorPtr& navFloorPtr, NavHalfEdgeIdx halfEdgeIdx)
188 {
189  m_navFloorPtr = navFloorPtr;
190  m_halfEdgeIdx = (CompactNavHalfEdgeIdx)halfEdgeIdx;
191 }
192 
193 KY_INLINE bool NavHalfEdgePtr::IsValid() const { return m_navFloorPtr.IsValid() && m_halfEdgeIdx != CompactNavHalfEdgeIdx_MAXVAL; }
194 
195 KY_INLINE void NavHalfEdgePtr::Invalidate() { m_navFloorPtr.Invalidate(); m_halfEdgeIdx = CompactNavHalfEdgeIdx_MAXVAL; }
196 
197 KY_INLINE bool NavHalfEdgePtr::operator==(const NavHalfEdgePtr& rhs) const { return m_navFloorPtr == rhs.m_navFloorPtr && m_halfEdgeIdx == rhs.m_halfEdgeIdx; }
198 KY_INLINE bool NavHalfEdgePtr::operator!=(const NavHalfEdgePtr& rhs) const { return !(*this == rhs); }
199 
201 
206 
208 
209 KY_INLINE const CellPos& NavHalfEdgePtr::GetCellPos() const { return GetRawPtr().GetCellPos(); }
210 KY_INLINE const NavTag& NavHalfEdgePtr::GetNavTag() const { return GetRawPtr().GetNavTag(); }
213 KY_INLINE CoordPos64 NavHalfEdgePtr::GetStartVertexCoordPos64() const { return GetRawPtr().GetStartVertexCoordPos64(); }
214 KY_INLINE CoordPos64 NavHalfEdgePtr::GetEndVertexCoordPos64() const { return GetRawPtr().GetEndVertexCoordPos64(); }
215 KY_INLINE KyFloat32 NavHalfEdgePtr::GetStartVertexAltitude() const { return GetRawPtr().GetStartVertexAltitude(); }
216 KY_INLINE KyFloat32 NavHalfEdgePtr::GetEndVertexAltitude() const { return GetRawPtr().GetEndVertexAltitude(); }
220 
221 KY_INLINE void NavHalfEdgePtr::GetTriangleVerticesPos3f(Vec3f& v0Pos3f, Vec3f& v1Pos3f, Vec3f& v2Pos3f) const
222 {
223  return GetRawPtr().GetTriangleVerticesPos3f(v0Pos3f, v1Pos3f, v2Pos3f);
224 }
225 KY_INLINE void NavHalfEdgePtr::GetVerticesPos3f(Vec3f& v0Pos3f, Vec3f& v1Pos3f) const
226 {
227  return GetRawPtr().GetVerticesPos3f(v0Pos3f, v1Pos3f);
228 }
229 template<class TraverseLogic>
230 KY_INLINE bool NavHalfEdgePtr::IsHalfEdgeCrossable(void* traverseLogicUserData) const
231 {
232  return GetRawPtr().IsHalfEdgeCrossable<TraverseLogic>(traverseLogicUserData);
233 }
234 
235 template<class TraverseLogic>
236 KY_INLINE NavHalfEdgePtr NavHalfEdgePtr::GetNextNavHalfEdgePtrAlongBorder(void* traverseLogicUserData) const
237 {
238  return NavHalfEdgePtr(GetRawPtr().GetNextNavHalfEdgeRawPtrAlongBorder<TraverseLogic>(traverseLogicUserData));
239 }
240 
241 template<class TraverseLogic>
242 KY_INLINE NavHalfEdgePtr NavHalfEdgePtr::GetPrevNavHalfEdgePtrAlongBorder(void* traverseLogicUserData) const
243 {
244  return NavHalfEdgePtr(GetRawPtr().GetPrevNavHalfEdgeRawPtrAlongBorder<TraverseLogic>(traverseLogicUserData));
245 }
246 
248 {
249  NavHalfEdgeRawPtr resultRawPtr;
250  bool storeResult = GetRawPtr().IsHalfEdgeCrossable(resultRawPtr);
251  resultPtr = NavHalfEdgePtr(resultRawPtr);
252  return storeResult;
253 }
254 
256 {
257  NavHalfEdgeRawPtr resultRawPtr;
258  GetRawPtr().GetPairHalfEdgeRawPtr(resultRawPtr);
259  resultPtr = NavHalfEdgePtr(resultRawPtr);
260 }
261 
263 {
264  NavHalfEdgeRawPtr resultRawPtr;
265  GetRawPtr().GetNextHalfEdgeRawPtr(resultRawPtr);
266  resultPtr = NavHalfEdgePtr(resultRawPtr);
267 }
268 
270 {
271  NavHalfEdgeRawPtr resultRawPtr;
272  GetRawPtr().GetPrevHalfEdgeRawPtr(resultRawPtr);
273  resultPtr = NavHalfEdgePtr(resultRawPtr);
274 }
275 
276 template<class TraverseLogic>
277 inline bool NavHalfEdgePtr::IsHalfEdgeCrossable(NavHalfEdgePtr& resultPtr, void* traverseLogicUserData) const
278 {
279  NavHalfEdgeRawPtr resultRawPtr;
280  bool storeResult = GetRawPtr().IsHalfEdgeCrossable<TraverseLogic>(resultRawPtr, traverseLogicUserData);
281  resultPtr = NavHalfEdgePtr(resultRawPtr);
282  return storeResult;
283 }
284 
285 
286 
287 }
288 
NavFloor * GetNavFloor() const
Returns a pointer to the NavFloor identified by this object. Returns nullptr if this object is not va...
Definition: navfloorptr.h:81
bool operator!=(const NavHalfEdgePtr &rhs) const
Returns true if this object identifies a different edge from rhs.
Definition: navhalfedgeptr.h:198
Vec3f GetStartVertexPos3f() const
Does set the z coordinate.
Definition: navhalfedgerawptr.cpp:104
Vec3f GetEndVertexPos3f() const
Returns the coordinates of the ending vertex of this NavHalfEdge.
Definition: navhalfedgeptr.h:212
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:219
NavHalfEdgeIdx GetHalfEdgeIdx() const
Returns the index of this edge within its NavFloor.
Definition: navhalfedgeptr.h:200
Each instance of this class uniquely identifies a single NavFloor.
Definition: navfloorptr.h:16
This class is a runtime wrapper of a NavFloorBlob, it gathers all the runtime information associated ...
Definition: navfloor.h:32
The NavFloorBlob contains a connected and not overlapping part of triangle mesh static data within a ...
Definition: navfloorblob.h:38
void Set(const NavFloorPtr &navFloorPtr, NavHalfEdgeIdx halfEdgeIdx)
Clears all information maintained by this object.
Definition: navhalfedgeptr.h:187
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:209
KyFloat32 GetEndVertexAltitude() const
Returns the altitude (z coordinate) of the ending vertex of this NavHalfEdge.
Definition: navhalfedgeptr.h:216
Vec3f GetStartVertexPos3f() const
Returns the coordinates of the starting vertex of this NavHalfEdge.
Definition: navhalfedgeptr.h:211
void GetVerticesPos3f(Vec3f &v0Pos3f, Vec3f &v1Pos3f) const
Updates the parameters to identify the start and end vertices of the specified edge.
Definition: navhalfedgeptr.h:225
void GetPrevHalfEdgeRawPtr(NavHalfEdgeRawPtr &prev) const
Updates prev to identify the previous edge in the triangle.
Definition: navhalfedgerawptr.inl:54
const NavFloorBlob * GetNavFloorBlob() const
Returns a const pointer to the NavFloorBlob that contains this edge. Returns nullptr if this object i...
Definition: navhalfedgeptr.h:203
void GetTriangleVerticesPos3f(Vec3f &start, Vec3f &end, Vec3f &next) const
next is the vertex in the (start->end->next) triangle
Definition: navhalfedgerawptr.cpp:14
NavFloor * GetNavFloor_Unsafe() const
Returns a pointer to the NavFloor identified by this object.
Definition: navfloorptr.h:84
void GetPrevHalfEdgePtr(NavHalfEdgePtr &resultPtr) const
Updates resultPtr to identify the previous edge in the triangle.
Definition: navhalfedgeptr.h:269
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:84
CompactNavHalfEdgeIdx m_halfEdgeIdx
The index of this edge within its NavFloor.
Definition: navhalfedgeptr.h:176
NavFloor * GetNavFloor() const
Returns a pointer to the NavFloor that contains this edge. Returns nullptr if this object is not vali...
Definition: navhalfedgeptr.h:202
CoordPos GetEndVertexCoordPosInCell() const
Returns the 2D integer coordinates of the ending vertex of this edge in its NavCell.
Definition: navhalfedgeptr.h:218
CoordPos GetStartVertexCoordPosInCell() const
Returns the start 2D integer coordinates (in pixels) relative to its NavCell origin.
Definition: navhalfedgerawptr.inl:50
void GetTriangleVerticesPos3f(Vec3f &v0Pos3f, Vec3f &v1Pos3f, Vec3f &v2Pos3f) const
Updates the parameters to identify the vertices in the specified triangle.
Definition: navhalfedgeptr.h:221
bool IsValid() const
Returns true if this object refers to a valid NavFloor, which means a NavFloor:that is not null...
Definition: navfloorptr.h:69
const NavTag & GetNavTag() const
Retrieves the NavTag associated to the NavFloor that contains this halfEdge.
Definition: navhalfedgeptr.h:210
CoordPos64 GetStartVertexCoordPos64() const
Returns the x,y integer coordinates of the starting vertex of this NavHalfEdge.
Definition: navhalfedgeptr.h:213
NavHalfEdgePtr GetNextNavHalfEdgePtrAlongBorder(void *traverseLogicUserData) const
Returns the next edge along the border of the NavMesh according to TraverseLogic. ...
Definition: navhalfedgeptr.h:236
2d vector using KyInt64
Definition: vec2ll.h:18
NavFloorPtr m_navFloorPtr
The NavFloor that contains this edge.
Definition: navhalfedgeptr.h:175
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
const NavFloorBlob * GetNavFloorBlob() const
Returns a const pointer to the NavFloorBlob identified by this object. Returns nullptr if this object...
Definition: navfloorptr.h:82
void GetNextHalfEdgeRawPtr(NavHalfEdgeRawPtr &next) const
Updates next to identify the next edge in the triangle.
Definition: navhalfedgerawptr.inl:53
const NavFloorBlob * GetNavFloorBlob_Unsafe() const
Returns a const pointer to the NavFloorBlob identified by this object.
Definition: navfloorptr.h:85
NavFloorRawPtr GetRawPtr() const
Constructs and returns a NavFloorRawPtr that refers to the same NavFloor.
Definition: navfloorptr.h:87
CoordPos GetStartVertexCoordPosInCell() const
Returns the 2D integer coordinates of the starting vertex of this edge in its NavCell.
Definition: navhalfedgeptr.h:217
void GetPairHalfEdgeRawPtr(NavHalfEdgeRawPtr &pair) const
Updates pair to identify the edge in the adjacent triangle that borders this edge.
Definition: navhalfedgerawptr.cpp:154
CoordPos64 GetEndVertexCoordPos64() const
Returns the x,y integer coordinates of the ending vertex of this NavHalfEdge.
Definition: navhalfedgeptr.h:214
NavHalfEdgePtr()
Creates an invalid NavHalfEdgePtr.
Definition: navhalfedgeptr.h:179
Vec3f GetEndVertexPos3f() const
Does set the z coordinate.
Definition: navhalfedgerawptr.cpp:125
2d vector using KyInt32
Definition: vec2i.h:18
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
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:193
CoordPos GetEndVertexCoordPosInCell() const
Returns the end 2D integer coordinates (in pixels) relative to its NavCell origin.
Definition: navhalfedgerawptr.inl:51
const NavFloorBlob * GetNavFloorBlob_Unsafe() const
Returns a const pointer to the NavFloorBlob that contains this edge.
Definition: navhalfedgeptr.h:205
NavFloor * GetNavFloor_Unsafe() const
All these function should be called only if IsValid() returns true.
Definition: navhalfedgeptr.h:204
NavHalfEdgeRawPtr GetRawPtr() const
Constructs and returns a NavHalfEdgeRawPtr that refers to the same NavHalfEdge.
Definition: navhalfedgeptr.h:207
void Invalidate()
Invalidates this object.
Definition: navhalfedgeptr.h:195
void GetPairHalfEdgePtr(NavHalfEdgePtr &resultPtr) const
Updates resultPtr to identify the edge in the next adjacent triangle that borders this edge...
Definition: navhalfedgeptr.h:255
NavHalfEdgePtr GetPrevNavHalfEdgePtrAlongBorder(void *traverseLogicUserData) const
Returns the previous edge along the border of the NavMesh according to TraverseLogic.
Definition: navhalfedgeptr.h:242
void Invalidate()
m_navFloorPtr = nullptr;
Definition: navfloorptr.h:68
Each instance of this class uniquely identifies a single NavHalfEdge in a NavFloor.
Definition: navhalfedgeptr.h:16
void GetNextHalfEdgePtr(NavHalfEdgePtr &resultPtr) const
Updates resultPtr to identify the next edge in the triangle.
Definition: navhalfedgeptr.h:262
bool IsHalfEdgeCrossable(void *traverseLogicUserData) const
Returns true if this edge can be traversed according the TraverseLogic.
Definition: navhalfedgerawptr.inl:89
KyFloat32 GetStartVertexAltitude() const
Returns the altitude (z coordinate) of the starting vertex of this NavHalfEdge.
Definition: navhalfedgeptr.h:215
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:197
Each instance of this class uniquely identifies a single NavHalfEdge in a NavFloor.
Definition: navhalfedgerawptr.h:23
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16