gwnavruntime/database/activenavfloorcollection.h Source File
Go to the documentation of this file.
19 class ActiveNavFloorCollection
24 ActiveNavFloorCollection() : m_activeNavFloors(
nullptr), m_count(0), m_capacity(0) {}
25 ~ActiveNavFloorCollection() { KY_LOG_ERROR_IF(m_activeNavFloors !=
nullptr, (
"memory leak !")); }
27 KY_INLINE
bool IsEmpty()
const {
return m_count == 0; }
28 KY_INLINE
KyUInt32 GetCount()
const {
return m_count; }
30 void GetOwnershipOfData(ActiveNavFloorCollection& other)
34 m_activeNavFloors = other.m_activeNavFloors;
35 m_count = other.m_count;
36 m_capacity = other.m_capacity;
38 other.m_activeNavFloors =
nullptr;
44 void InsertActiveNavFloorsOfNavCell(MemoryHeap* heap, NavCell* navCell)
46 const KyUInt32 numberOfNavFloorInCell = navCell->GetNavFloorCount();
47 const KyUInt32 previousCount = m_count;
49 KyUInt32 newCapacity = Max<KyUInt32>(4, m_capacity);
50 if (m_count + numberOfNavFloorInCell > m_capacity)
52 while(previousCount + numberOfNavFloorInCell > newCapacity)
55 Reserve(heap, newCapacity);
59 m_count = m_count + (
KyUInt16)numberOfNavFloorInCell;
60 KY_ASSERT(m_count <= m_capacity);
62 NavFloor** navFloors = GetNavFloors() + previousCount;
63 for(
KyUInt32 idx = 0; idx < numberOfNavFloorInCell; ++idx)
64 navFloors[idx] = navCell->GetNavFloor(idx);
67 NavFloor** GetNavFloors()
const {
return m_activeNavFloors; }
69 void Reserve(MemoryHeap* heap,
KyUInt32 newCapacity)
71 KY_DEBUG_ASSERTN(newCapacity > m_capacity, (
"no shrinking !"));
73 char* newData = (
char*)KY_HEAP_ALLOC(heap, newCapacity * (
KyUInt32)
sizeof(NavFloor*), MemStat_NavData);
75 #if defined(KY_CONFIG_DEBUG)
76 memset(newData, 0xFE, newCapacity * (
KyUInt32)
sizeof(NavFloor*));
82 memcpy(newData, (
char*)m_activeNavFloors, m_count *
sizeof(NavFloor*));
84 KY_FREE(m_activeNavFloors);
88 m_activeNavFloors = (NavFloor**)newData;
93 #if defined(KY_CONFIG_DEBUG)
95 memset((
char*)m_activeNavFloors, 0, m_capacity * ((
KyUInt32)
sizeof(NavFloor*)));
104 KY_FREE(m_activeNavFloors);
108 m_activeNavFloors =
nullptr;
112 KY_ASSERT(m_count == 0);
113 KY_ASSERT(m_capacity == 0);
114 KY_ASSERT(m_activeNavFloors ==
nullptr);
119 NavFloor** m_activeNavFloors;
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
std::uint16_t KyUInt16
uint16_t
Definition: types.h:28
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17