gwnavruntime/navmesh/navmeshelement.h Source File

navmeshelement.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 
14 class NavCell;
15 class Database;
16 
22 {
23  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
26 
27 public:
28  // ------------------------------ Functions -----------------------------
29 
31  bool IsStillLoaded() const { return m_navMeshElementBlob != nullptr; }
32 
33  const NavMeshElementBlob* GetNavMeshElementBlob() const
34  {
35  KY_DEBUG_ASSERTN(IsStillLoaded(), ("You Cannot call this function if NavMeshElement has been unloaded or not loaded yet"));
36  return m_navMeshElementBlob;
37  }
38 
40  const GuidCompound& GetGuidCompound() const
41  {
42  KY_DEBUG_ASSERTN(IsStillLoaded(), ("You Cannot call this function if NavMeshElement has been unloaded or not loaded yet"));
43  return m_navMeshElementBlob->m_guidCompound;
44  }
45 
46 public: // internal
47  void OnRemove(); // Call OnRemove on each NavCell
48 
49  KyUInt32 GetIndexInCollection() const { return m_indexInCollection; } // contract to be in a TrackedCollection
50  void SetIndexInCollection(KyUInt32 indexInCollection) { m_indexInCollection = indexInCollection; } // contract to be in a TrackedCollection
51 
52  static Ptr<NavMeshElement> Create(const NavMeshElementBlob& navMeshElementBlob, Database* database, MemoryHeap* pheap = nullptr);
53 
54 private:
55  static KyUInt32 ComputeSizeForNavMeshElement(const NavMeshElementBlob& navMeshElementBlob)
56  {
57  return sizeof(NavMeshElement) + navMeshElementBlob.GetNavCellBlobCount() * (KyUInt32)sizeof(void*);
58  }
59 
60  static KyUInt32 ComputeTotalSizeForNavMeshElement(const NavMeshElementBlob& navMeshElementBlob);
61 
62 public: // internal
63  Database* m_database; // The Database in which the parentNavData has been added to. Do not modify.
64  NavCell** m_navCells; // The array of NavCells that make up this NavMeshElement. Do not modify.
65  KyUInt32 m_numberOfCells; // The number of NavCells in #m_navCells. Do not modify.
66 
67  KyUInt32 m_indexInCollection; // For TrackedCollection
68  KyUInt32 m_guidCompoundSortedIdx;
69  bool m_guidCompoundIsCompatible;
70 
71 private:
72  const NavMeshElementBlob* m_navMeshElementBlob; // The NavMeshElementBlob that contains the static data for this NavMesh. Do not modify.
73 };
74 }
const GuidCompound & GetGuidCompound() const
Returns the GuidCompound that uniquely identifies this NavMeshElement.
Definition: navmeshelement.h:40
This class is a runtime wrapper of a NavMeshElementBlob.
Definition: navmeshelement.h:21
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
GuidCompound m_guidCompound
The GuidCompound that uniquely identifies this NavMeshElementBlob. For internal use. Do not modify.
Definition: navmeshelementblob.h:76
#define KY_REFCOUNT_MALLOC_FREE(ClassName)
Specific to RefCounting, no inheritance involved, used to make RefCount-able classes compatible with ...
Definition: memory.h:141
bool IsStillLoaded() const
Returns false if the NavData containing corresponding NavMeshElementBlob has been removed from the Da...
Definition: navmeshelement.h:31
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
The NavMeshElementBlob contains the NavMesh static data (a set of NavCellBlob) for an element (a Guid...
Definition: navmeshelementblob.h:46