gwnavruntime/navmesh/identifiers/navfloorptr.h Source File

navfloorptr.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  // ---------------------------------- Main API Functions ----------------------------------
21 
23  NavFloorPtr(NavFloor* navFloor = nullptr);
24 
26  explicit NavFloorPtr(const NavFloorRawPtr& navFloorRawPtr);
27 
33  bool IsValid() const;
34 
35  void Invalidate();
36 
37  bool operator==(const NavFloorPtr& rhs) const;
38  bool operator!=(const NavFloorPtr& rhs) const;
39 
40  NavFloor* GetNavFloor() const;
41  const NavFloorBlob* GetNavFloorBlob() const;
42 
43  // ---------------------------------- Member Functions for valid instance ----------------------------------
45 
49 
52  const NavFloorBlob* GetNavFloorBlob_Unsafe() const;
53 
56  NavFloorRawPtr GetRawPtr() const;
57 
60  const CellPos& GetCellPos() const;
61 
62 private:
63  mutable Ptr<NavFloor> m_navFloorPtr;
64 };
65 
66 KY_INLINE NavFloorPtr::NavFloorPtr(NavFloor* navFloor) : m_navFloorPtr(navFloor) {}
67 KY_INLINE NavFloorPtr::NavFloorPtr(const NavFloorRawPtr& navFloorRawPtr) : m_navFloorPtr(navFloorRawPtr.GetNavFloor()) {}
68 KY_INLINE void NavFloorPtr::Invalidate() { m_navFloorPtr = nullptr; }
69 KY_INLINE bool NavFloorPtr::IsValid() const
70 {
71  if (m_navFloorPtr != nullptr)
72  {
73  if (m_navFloorPtr->IsStillLoaded())
74  return m_navFloorPtr->IsActive();
75  m_navFloorPtr = nullptr;
76  }
77  return false;
78 }
79 
80 
81 KY_INLINE NavFloor* NavFloorPtr::GetNavFloor() const { return IsValid() ? GetNavFloor_Unsafe() : nullptr; }
82 KY_INLINE const NavFloorBlob* NavFloorPtr::GetNavFloorBlob() const { return IsValid() ? GetNavFloorBlob_Unsafe() : nullptr; }
83 
84 KY_INLINE NavFloor* NavFloorPtr::GetNavFloor_Unsafe() const { return m_navFloorPtr; }
85 KY_INLINE const NavFloorBlob* NavFloorPtr::GetNavFloorBlob_Unsafe() const { return m_navFloorPtr->GetNavFloorBlob(); }
86 
87 KY_INLINE NavFloorRawPtr NavFloorPtr::GetRawPtr() const { return NavFloorRawPtr(m_navFloorPtr.GetPtr()); }
88 
89 KY_INLINE bool NavFloorPtr::operator==(const NavFloorPtr& rhs) const { return m_navFloorPtr == rhs.m_navFloorPtr; }
90 KY_INLINE bool NavFloorPtr::operator!=(const NavFloorPtr& rhs) const { return m_navFloorPtr != rhs.m_navFloorPtr; }
91 
92 KY_INLINE const CellPos& NavFloorPtr::GetCellPos() const { return GetRawPtr().GetCellPos(); }
93 
94 }
95 
96 
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
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
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:77
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:92
NavFloor * GetNavFloor_Unsafe() const
Returns a pointer to the NavFloor identified by this object.
Definition: navfloorptr.h:84
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
#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
const NavFloorBlob * GetNavFloorBlob_Unsafe() const
Returns a const pointer to the NavFloorBlob identified by this object.
Definition: navfloorptr.h:85
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:89
NavFloorRawPtr GetRawPtr() const
Constructs and returns a NavFloorRawPtr that refers to the same NavFloor.
Definition: navfloorptr.h:87
NavFloorPtr(NavFloor *navFloor=nullptr)
Creates an invalid NavFloorPtr.
Definition: navfloorptr.h:66
2d vector using KyInt32
Definition: vec2i.h:18
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
void Invalidate()
m_navFloorPtr = nullptr;
Definition: navfloorptr.h:68
Each instance of this class uniquely identifies a single NavFloor.
Definition: navfloorrawptr.h:23
bool operator!=(const NavFloorPtr &rhs) const
Returns true if this object identifies a different NavFloor from rhs.
Definition: navfloorptr.h:90