gwnavruntime/database/navtagptr.h Source File

navtagptr.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 
15 
16 namespace Kaim
17 {
18 
21 class NavTagPtr
22 {
23  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
24 
25 public:
26  // ---------------------------------- Constructors ----------------------------------
27 
29  NavTagPtr();
30 
32  NavTagPtr(const NavTrianglePtr& navTrianglePtr);
33 
35  NavTagPtr(const NavGraphEdgePtr& navGraphEdgePtr);
36 
38  NavTagPtr(const NavGraphVertexPtr& navGraphVertexPtr);
39 
40 
41  // ---------------------------------- Main API Functions ----------------------------------
42 
44  bool IsValid() const;
45 
47  void Invalidate();
48 
50  bool operator==(const NavTagPtr& rhs) const;
51 
53  bool operator!=(const NavTagPtr& rhs) const;
54 
55  const NavTag* GetNavTag() const
56  {
57  if(IsValid() == false)
58  return nullptr;
59 
60  if(m_navFloorPtr != nullptr)
61  return &m_navFloorPtr->m_navTags[m_navTagIdx];
62  else
63  return &m_navGraphPtr->m_navTags[m_navTagIdx];
64  }
65 
66 public: //internal
67  mutable Ptr<NavFloor> m_navFloorPtr;
68  mutable Ptr<NavGraph> m_navGraphPtr;
69  NavTagIdx m_navTagIdx;
70 };
71 
72 KY_INLINE NavTagPtr::NavTagPtr() : m_navTagIdx(NavTagIdx_Invalid) {}
73 KY_INLINE NavTagPtr::NavTagPtr(const NavTrianglePtr& navTrianglePtr)
74 {
75  if (navTrianglePtr.IsValid())
76  {
77  m_navFloorPtr = navTrianglePtr.GetNavFloor();
78  m_navTagIdx = navTrianglePtr.GetNavFloorBlob_Unsafe()->NavTriangleIdxToNavConnexIdx(navTrianglePtr.GetTriangleIdx());
79  }
80 }
81 KY_INLINE NavTagPtr::NavTagPtr(const NavGraphEdgePtr& navGraphEdgePtr)
82 {
83  if (navGraphEdgePtr.IsValid())
84  {
85  m_navGraphPtr = navGraphEdgePtr.GetNavGraph();
86  m_navTagIdx = navGraphEdgePtr.GetNavGraphBlob_UnSafe()->GetNavGraphEdgeNavTagIdx(navGraphEdgePtr.m_edgeSmartIdx);
87  }
88 }
89 KY_INLINE NavTagPtr::NavTagPtr(const NavGraphVertexPtr& navGraphVertexPtr)
90 {
91  if (navGraphVertexPtr.IsValid())
92  {
93  m_navGraphPtr = navGraphVertexPtr.GetNavGraph();
94  m_navTagIdx = navGraphVertexPtr.GetNavGraphBlob_UnSafe()->GetNavGraphVertexNavTagIdx(navGraphVertexPtr.GetNavGraphVertexIdx());
95  }
96 }
97 
98 KY_INLINE void NavTagPtr::Invalidate() { m_navFloorPtr = nullptr; m_navGraphPtr = nullptr; m_navTagIdx = NavTagIdx_Invalid; }
99 KY_INLINE bool NavTagPtr::IsValid() const { return (m_navFloorPtr != nullptr || m_navGraphPtr != nullptr) && m_navTagIdx != NavTagIdx_Invalid; }
100 
101 KY_INLINE bool NavTagPtr::operator==(const NavTagPtr& rhs) const { return m_navFloorPtr == rhs.m_navFloorPtr && m_navGraphPtr == rhs.m_navGraphPtr && m_navTagIdx == rhs.m_navTagIdx; }
102 KY_INLINE bool NavTagPtr::operator!=(const NavTagPtr& rhs) const { return m_navFloorPtr != rhs.m_navFloorPtr || m_navGraphPtr != rhs.m_navGraphPtr || m_navTagIdx != rhs.m_navTagIdx; }
103 
104 }
105 
106 
bool IsValid() const
Returns true if this object refers to a valid triangle: i.e. a triangle in a validNavFloor. see NavFloorPtr::IsValid().
Definition: navtriangleptr.h:123
bool IsValid() const
Returns true if this object refers to a valid NavGraphVertex: i.e. a NavGraphVertex in a validNavGrap...
Definition: navgraphvertexptr.h:100
NavFloor * GetNavFloor() const
Returns a pointer to the NavFloor that contains this triangle. Returns nullptr if this object is not ...
Definition: navtriangleptr.h:132
const NavGraphBlob * GetNavGraphBlob_UnSafe() const
Returns a pointer to the NavGraphBlob identified by this object.
Definition: navgraphvertexptr.h:112
const NavGraphBlob * GetNavGraphBlob_UnSafe() const
Returns a pointer to the NavGraphBlob identified by this object.
Definition: navgraphedgeptr.h:122
NavTriangleIdx GetTriangleIdx() const
Returns the index of this triangle within its NavFloor.
Definition: navtriangleptr.h:130
NavConnexIdx NavTriangleIdxToNavConnexIdx(NavTriangleIdx idx) const
Retrieves the index of the NavConnex associated to the triangle specified by the input NavTriangleIdx...
Definition: navfloorblob.inl:109
Each instance of this class uniquely identifies a single NavFloor.
Definition: navtagptr.h:21
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
NavGraph * GetNavGraph() const
Returns a pointer to the NavGraph that handles the graph identified by this object.
Definition: navgraphvertexptr.h:109
bool operator!=(const NavTagPtr &rhs) const
Definition: navtagptr.h:102
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Each instance of this class uniquely identifies a single NavGraphVertex in a NavGraph.
Definition: navgraphvertexptr.h:17
NavGraphVertexIdx GetNavGraphVertexIdx() const
Returns the GraphVertexIdx that identifies this vertex within its Graph.
Definition: navgraphvertexptr.h:108
const NavFloorBlob * GetNavFloorBlob_Unsafe() const
Returns a const pointer to the NavFloorBlob that contains this triangle.
Definition: navtriangleptr.h:135
bool IsValid() const
Definition: navtagptr.h:99
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:17
bool IsValid() const
Returns true if this object refers to a valid NavGraphEdge: i.e. a NavGraphEdge in a valid NavGraph...
Definition: navgraphedgeptr.h:115
NavTagPtr()
Creates an invalid NavTagPtr.
Definition: navtagptr.h:72
Each instance of this class uniquely identifies a single and mono-directionnal NavGraphEdge in a NavG...
Definition: navgraphedgeptr.h:20
void Invalidate()
Invalidates this object.
Definition: navtagptr.h:98
bool operator==(const NavTagPtr &rhs) const
Definition: navtagptr.h:101
NavGraph * GetNavGraph() const
Returns a pointer to the NavGraph that handles the graph identified by this object.
Definition: navgraphedgeptr.h:119