16 class AstarNodeIndexInGrid;
19 class NavDataChangeIndexInGrid
24 struct CellPosNavMeshChangeIdx
26 KY_INLINE
bool IsValid()
const {
return m_navMeshChangeIdx != 0; }
31 NavDataChangeIndexInGrid() : m_currentOffsetFromBuffer(0), m_navGraphChangeIdx(0) {}
33 NavDataChangeIndexInGrid(WorkingMemory* workingMemory,
const CellBox& cellBox) :
34 m_navGraphChangeIdx(0), m_abstractGraphChangeIdx(0), m_cellBox(cellBox)
36 m_buffer.Init(workingMemory);
37 m_currentOffsetFromBuffer = 0;
41 ~NavDataChangeIndexInGrid() { ReleaseWorkingMemoryBuffer(); }
43 void Init(WorkingMemory* workingMemory,
const CellBox& cellBox)
45 m_buffer.Init(workingMemory);
47 m_currentOffsetFromBuffer = 0;
48 m_navGraphChangeIdx = 0;
49 m_abstractGraphChangeIdx = 0;
54 void InitAllChangeIdxFromAstarNodeIndexInGrid(AstarNodeIndexInGrid& astarNodeIndexInGrid);
55 void InitAllChangeIdxFromDatabase(
const Database* database);
57 void ReleaseWorkingMemoryBuffer();
59 KyUInt32 GetAvailableSizeInBytes()
const;
61 bool IsEnoughPlaceForAllocation(
KyUInt32 sizeInBytes);
67 void* AllocateInBufferAndMemsetTo0(
KyUInt32 sizeOfOneElementInBytes,
KyUInt32 numberOfElements);
69 CellPosNavMeshChangeIdx* AllocateCellPosNavDataIdx(
KyUInt32 numberOfCell);
70 CellPosNavMeshChangeIdx* GetCellPosNavDataIdx(
const CellPos& cellPos);
72 bool IsInitialized()
const {
return m_buffer.IsInitialized(); }
73 bool HasVisitedNavDataChanged(Database* database, PathFinderAbstractGraphTraversalMode abstractGraphTraversalMode);
76 WorkingMemContainerBase m_buffer;
83 KY_INLINE
void NavDataChangeIndexInGrid::ReleaseWorkingMemoryBuffer() { m_buffer.ReleaseBuffer(); }
85 KY_INLINE
KyUInt32 NavDataChangeIndexInGrid::GetAvailableSizeInBytes()
const {
return m_buffer.GetBufferSize() - m_currentOffsetFromBuffer; }
87 KY_INLINE
bool NavDataChangeIndexInGrid::IsEnoughPlaceForAllocation(
KyUInt32 sizeInBytes)
89 while (GetAvailableSizeInBytes() < sizeInBytes)
91 if (TryToResize() ==
false)
98 KY_INLINE NavDataChangeIndexInGrid::CellPosNavMeshChangeIdx* NavDataChangeIndexInGrid::AllocateCellPosNavDataIdx(
KyUInt32 numberOfCell)
100 return (CellPosNavMeshChangeIdx*)AllocateInBufferAndMemsetTo0(
sizeof(CellPosNavMeshChangeIdx), numberOfCell);
103 KY_INLINE NavDataChangeIndexInGrid::CellPosNavMeshChangeIdx* NavDataChangeIndexInGrid::GetCellPosNavDataIdx(
const CellPos& cellPos)
105 CellPosNavMeshChangeIdx* memoryStartForGrid = (CellPosNavMeshChangeIdx*)(m_buffer.GetBuffer());
106 return memoryStartForGrid + m_cellBox.GetRowMajorIndex(cellPos);
Box2i CellBox
A type that represents a bounding box around cells in a 2D grid.
Definition: navmeshtypes.h:31
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:30
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
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17