gwnavruntime/navmesh/identifiers/navfloorptr.h Source File

navfloorptr.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 
9 // ---------- Primary contact: JUBA - secondary contact: NOBODY
10 #ifndef Navigation_NavFloorPtr_H
11 #define Navigation_NavFloorPtr_H
12 
14 
15 namespace Kaim
16 {
17 
20 class NavFloorPtr
21 {
22  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
23 public:
24  // ---------------------------------- Main API Functions ----------------------------------
25 
27  NavFloorPtr(NavFloor* navFloor = KY_NULL);
28 
30  explicit NavFloorPtr(const NavFloorRawPtr& navFloorRawPtr);
31 
36  bool IsValid() const;
37 
38  void Invalidate();
39 
40  bool operator==(const NavFloorPtr& rhs) const;
41  bool operator!=(const NavFloorPtr& rhs) const;
42 
43  NavFloor* GetNavFloor() const;
44  const NavFloorBlob* GetNavFloorBlob() const;
45 
46  // ---------------------------------- Member Functions for valid instance ----------------------------------
48 
52 
55  const NavFloorBlob* GetNavFloorBlob_Unsafe() const;
56 
59  NavFloorRawPtr GetRawPtr() const;
60 
63  const CellPos& GetCellPos() const;
64 
65 private:
66  mutable Ptr<NavFloor> m_navFloorPtr;
67 };
68 
69 KY_INLINE NavFloorPtr::NavFloorPtr(NavFloor* navFloor) : m_navFloorPtr(navFloor) {}
70 KY_INLINE NavFloorPtr::NavFloorPtr(const NavFloorRawPtr& navFloorRawPtr) : m_navFloorPtr(navFloorRawPtr.GetNavFloor()) {}
71 KY_INLINE void NavFloorPtr::Invalidate() { m_navFloorPtr = KY_NULL; }
72 KY_INLINE bool NavFloorPtr::IsValid() const
73 {
74  if(m_navFloorPtr != KY_NULL)
75  {
76  if(m_navFloorPtr->IsStillLoaded())
77  return m_navFloorPtr->IsActive();
78 
79  m_navFloorPtr = KY_NULL;
80  }
81 
82  return false;
83 }
84 
85 
86 KY_INLINE NavFloor* NavFloorPtr::GetNavFloor() const { return IsValid() ? GetNavFloor_Unsafe() : KY_NULL; }
87 KY_INLINE const NavFloorBlob* NavFloorPtr::GetNavFloorBlob() const { return IsValid() ? GetNavFloorBlob_Unsafe() : KY_NULL; }
88 
89 KY_INLINE NavFloor* NavFloorPtr::GetNavFloor_Unsafe() const { return m_navFloorPtr; }
90 KY_INLINE const NavFloorBlob* NavFloorPtr::GetNavFloorBlob_Unsafe() const { return m_navFloorPtr->GetNavFloorBlob(); }
91 
92 KY_INLINE NavFloorRawPtr NavFloorPtr::GetRawPtr() const { return NavFloorRawPtr(m_navFloorPtr.GetPtr()); }
93 
94 KY_INLINE bool NavFloorPtr::operator==(const NavFloorPtr& rhs) const { return m_navFloorPtr == rhs.m_navFloorPtr; }
95 KY_INLINE bool NavFloorPtr::operator!=(const NavFloorPtr& rhs) const { return m_navFloorPtr != rhs.m_navFloorPtr; }
96 
97 KY_INLINE const CellPos& NavFloorPtr::GetCellPos() const { return GetRawPtr().GetCellPos(); }
98 
99 }
101 #endif //Navigation_NavFloorPtr_H
102 
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
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
const CellPos & GetCellPos() const
Returns a const reference to the CellPos that indicates the position of the cell that contains this N...
Definition: navfloorrawptr.h:86
const CellPos & GetCellPos() const
Returns a const reference to the CellPos that indicates the position of the cell that contains this N...
Definition: navfloorptr.h:108
NavFloor * GetNavFloor_Unsafe() const
Returns a pointer to the NavFloor identified by this object.
Definition: navfloorptr.h:100
#define KY_NULL
Null value.
Definition: types.h:247
bool IsValid() const
Returns true if this object refers to a valid NavFloor, which means a NavFloor:that exists...
Definition: navfloorptr.h:83
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
bool operator==(const NavFloorPtr &rhs) const
Returns true if this object identifies the same NavFloor as rhs, or if both are invalid.
Definition: navfloorptr.h:105
NavFloorRawPtr GetRawPtr() const
Constructs and returns a NavFloorRawPtr that refers to the same NavFloor.
Definition: navfloorptr.h:103
This class defines a two-dimensional vector whose coordinates are stored using 32-bit integers...
Definition: vec2i.h:26
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
NavFloorPtr(NavFloor *navFloor=0)
Creates an invalid NavFloorPtr.
Definition: navfloorptr.h:80
void Invalidate()
Invalidates this object.
Definition: navfloorptr.h:82
Each instance of this class uniquely identifies a single NavFloor.
Definition: navfloorrawptr.h:30
bool operator!=(const NavFloorPtr &rhs) const
Returns true if this object identifies a different NavFloor from rhs.
Definition: navfloorptr.h:106