7 #ifndef Navigation_TriangleStatusInGrid_H
8 #define Navigation_TriangleStatusInGrid_H
17 class TriangleStatusInGrid
22 typedef StatusInGridBase::IndexedStatus NavFloorToTriangles;
23 typedef StatusInGridBase::IntermediateStatusAccessor<NavFloorToTriangles> CellPosToNavFloors;
26 TriangleStatusInGrid(WorkingMemory* workingMemory,
const CellBox& cellBox) :
27 m_statusInGridBase(workingMemory, cellBox)
34 KY_INLINE NavFloorToTriangles* AllocateNavFloorToTriangles(
KyUInt32 numberofFloors);
35 KY_INLINE CellPosToNavFloors* AllocateCellPosToNavCells(
KyUInt32 numberOfNavCell);
36 KY_INLINE CellPosToNavFloors* GetCellPosToNavFloors(
const CellPos& cellPos);
38 TraversalResult OpenNodeIfNew(ActiveData& activeData,
const NavTriangleRawPtr& triangleRawPtr,
bool& nodeWasNew);
39 bool IsTriangleOpen(
const NavTriangleRawPtr& triangleRawPtr)
const;
41 KY_INLINE
bool IsTriangleOpen_Unsafe(
const NavTriangleRawPtr& triangleRawPtr)
const;
43 KY_INLINE
bool IsInitialized()
const {
return m_statusInGridBase.IsInitialized(); }
45 void ReleaseWorkingMemoryBuffer() { m_statusInGridBase.ReleaseWorkingMemoryBuffer(); }
47 StatusInGridBase m_statusInGridBase;
50 KY_INLINE TriangleStatusInGrid::NavFloorToTriangles* TriangleStatusInGrid::AllocateNavFloorToTriangles(
KyUInt32 numberofFloors)
52 return (NavFloorToTriangles*)m_statusInGridBase.AllocateInBufferAndMemset(
sizeof(NavFloorToTriangles), numberofFloors, 0xFF);
55 KY_INLINE TriangleStatusInGrid::CellPosToNavFloors* TriangleStatusInGrid::AllocateCellPosToNavCells(
KyUInt32 numberOfNavCell)
57 return (CellPosToNavFloors*)m_statusInGridBase.AllocateInBufferAndMemset(
sizeof(CellPosToNavFloors), numberOfNavCell, 0xFF);
60 KY_INLINE
bool TriangleStatusInGrid::IsTriangleOpen_Unsafe(
const NavTriangleRawPtr& triangleRawPtr)
const
62 KY_DEBUG_ASSERTN(m_statusInGridBase.m_cellBox.IsInside(triangleRawPtr.GetCellPos()), (
"Invalid CellBox"));
64 NavFloor* navFloor = triangleRawPtr.GetNavFloor();
65 const CellPos& cellPos = navFloor->GetCellPos();
67 CellPosToNavFloors& cellPosToNavFloors = ((CellPosToNavFloors*)m_statusInGridBase.GetBuffer())[m_statusInGridBase.m_cellBox.GetRowMajorIndex(cellPos)];
68 KY_DEBUG_ASSERTN(cellPosToNavFloors.IsValid(), (
"Unsafe mode, it should never happen"));
70 NavFloorToTriangles& navFloorToTriangles = *cellPosToNavFloors.GetUnderlyingObject(navFloor->GetIndexInCollection());
71 KY_DEBUG_ASSERTN(navFloorToTriangles.IsValid(), (
"Unsafe mode, it should never happen"));
73 return navFloorToTriangles.IsNodeOpen(triangleRawPtr.GetTriangleIdx());
76 KY_INLINE TriangleStatusInGrid::CellPosToNavFloors* TriangleStatusInGrid::GetCellPosToNavFloors(
const CellPos& cellPos)
78 return (CellPosToNavFloors*)m_statusInGridBase.GetBuffer() + m_statusInGridBase.m_cellBox.GetRowMajorIndex(cellPos);
Box2i CellBox
A type that represents a bounding box around cells in a 2D grid.
Definition: navmeshtypes.h:34
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:33
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36