9 #ifndef Navigation_PathRefinerContext_H
10 #define Navigation_PathRefinerContext_H
18 static const RefinerNodeIndex RefinerNodeIndex_Invalid =
KyUInt16MAXVAL;
24 RefinerNode(
const Vec3f& pos, NodeTypeAndRawPtrDataIdx nodeTypeAndRawPtrDataIdx, RefinerNodeIndex predecessorIdx, RefinerNodeIndex nextNodeIdx);
26 PathNodeType GetNodeType()
const;
29 void SetNodeType(PathNodeType nodeType);
30 void SetIdxOfRawPtrData(
KyUInt32 indexOfRawPtrData);
33 WorldIntegerPos m_nodeIntegerPos;
37 NodeTypeAndRawPtrDataIdx m_nodeTypeAndRawPtrDataIdx;
38 RefinerNodeIndex m_predecessorNodeIdx;
39 RefinerNodeIndex m_nextNodeIdx;
40 IndexInBinHeap m_indexInBinaryHeap;
43 class RefinerBinHeapIndexTracker
46 RefinerBinHeapIndexTracker() : m_refinerNodes(
KY_NULL) {}
48 void SetRefinerNodeArray(WorkingMemArray<RefinerNode>& refinerNodes);
50 void OnAdd(RefinerNodeIndex refinerNodeIndex,
KyUInt32 indexInBinaryHeap);
52 void OnRemove(RefinerNodeIndex refinerNodeIndex);
54 void OnSwap(RefinerNodeIndex lhs, RefinerNodeIndex rhs);
56 WorkingMemArray<RefinerNode>* m_refinerNodes;
59 class RefinerNodeComparator
62 RefinerNodeComparator() : m_refinerNodes(
KY_NULL) {}
63 void SetRefinerNodeArray(WorkingMemArray<RefinerNode>& refinerNodes);
64 bool operator () (
const RefinerNodeIndex lhsIdx,
const RefinerNodeIndex rhsIdx)
const;
66 WorkingMemArray<RefinerNode>* m_refinerNodes;
69 typedef WorkingMemBinaryHeap<RefinerNodeIndex, RefinerNodeComparator, RefinerBinHeapIndexTracker> RefinerBinHeap;
71 class AStarTraversalContext;
72 class PathRefinerContext
76 PathRefinerContext() : m_currentNodeIdx(RefinerNodeIndex_Invalid) {}
77 ~PathRefinerContext() { ReleaseWorkingMemory(); }
79 KyResult InitFromAstarTraversalContext(WorkingMemory* workingMemory, AStarTraversalContext* astarContext,
80 AStarNodeIndex destinationNodeIdx,
bool doClearAStarTraversalContext =
true);
82 void ReleaseWorkingMemory();
85 RefinerBinHeap m_refinerBinHeap;
86 WorkingMemArray<RefinerNode> m_refinerNodes;
87 WorkingMemArray<NavTriangleRawPtr> m_triangleRawPtrNodes;
88 WorkingMemArray<NavGraphVertexRawPtr> m_vertexRawPtrNodes;
90 RefinerNodeIndex m_currentNodeIdx;
94 KY_INLINE RefinerNode::RefinerNode() :
98 m_predecessorNodeIdx(RefinerNodeIndex_Invalid),
99 m_nextNodeIdx(RefinerNodeIndex_Invalid),
100 m_indexInBinaryHeap(IndexInBinHeap_UnSet)
103 KY_INLINE RefinerNode::RefinerNode(
const Vec3f& pos, NodeTypeAndRawPtrDataIdx nodeTypeAndRawPtrDataIdx, RefinerNodeIndex predecessorIdx, RefinerNodeIndex nextNodeIdx) :
108 m_nodeTypeAndRawPtrDataIdx(nodeTypeAndRawPtrDataIdx),
109 m_predecessorNodeIdx(predecessorIdx),
110 m_nextNodeIdx(nextNodeIdx),
111 m_indexInBinaryHeap(IndexInBinHeap_UnSet)
114 KY_INLINE PathNodeType RefinerNode:: GetNodeType()
const {
return m_nodeTypeAndRawPtrDataIdx.GetNodeType(); }
115 KY_INLINE
KyUInt32 RefinerNode::GetIdxOfRawPtrData()
const {
return m_nodeTypeAndRawPtrDataIdx.GetIdxOfRawPtrData(); }
116 KY_INLINE
void RefinerNode::SetNodeType(PathNodeType nodeType) { m_nodeTypeAndRawPtrDataIdx.SetNodeType(nodeType); }
117 KY_INLINE
void RefinerNode::SetIdxOfRawPtrData(
KyUInt32 indexOfRawPtrData) { m_nodeTypeAndRawPtrDataIdx.SetIdxOfRawPtrData(indexOfRawPtrData); }
120 KY_INLINE
void RefinerBinHeapIndexTracker::SetRefinerNodeArray(WorkingMemArray<RefinerNode>& refinerNodes) { m_refinerNodes = &refinerNodes; }
121 KY_INLINE
void RefinerBinHeapIndexTracker::OnAdd(RefinerNodeIndex refinerNodeIndex,
KyUInt32 indexInBinaryHeap)
123 RefinerNode& node = (*m_refinerNodes)[refinerNodeIndex];
124 node.m_indexInBinaryHeap = (IndexInBinHeap)indexInBinaryHeap;
126 KY_INLINE
void RefinerBinHeapIndexTracker::OnRemove(RefinerNodeIndex refinerNodeIndex)
128 RefinerNode& node = (*m_refinerNodes)[refinerNodeIndex];
129 node.m_indexInBinaryHeap = IndexInBinHeap_UnSet;
131 KY_INLINE
void RefinerBinHeapIndexTracker::OnSwap(RefinerNodeIndex lhs, RefinerNodeIndex rhs)
133 RefinerNode& node1 = (*m_refinerNodes)[lhs];
134 RefinerNode& node2 = (*m_refinerNodes)[rhs];
135 Alg::Swap(node1.m_indexInBinaryHeap, node2.m_indexInBinaryHeap);
138 KY_INLINE
void RefinerNodeComparator::SetRefinerNodeArray(WorkingMemArray<RefinerNode>& refinerNodes) { m_refinerNodes = &refinerNodes; }
139 KY_INLINE
bool RefinerNodeComparator::operator() (
const RefinerNodeIndex lhsIdx,
const RefinerNodeIndex rhsIdx)
const
141 RefinerNode& lhs = (*m_refinerNodes)[lhsIdx];
142 RefinerNode& rhs = (*m_refinerNodes)[rhsIdx];
143 return lhs.m_refinerCost < rhs.m_refinerCost;
146 KY_INLINE
void PathRefinerContext::ReleaseWorkingMemory()
148 m_triangleRawPtrNodes.ReleaseWorkingMemoryBuffer();
149 m_vertexRawPtrNodes.ReleaseWorkingMemoryBuffer();
150 m_refinerBinHeap.ReleaseWorkingMemoryBuffer();
151 m_refinerNodes.ReleaseWorkingMemoryBuffer();
157 #endif //Navigation_PathRefinerContext_H
#define KyFloat32MAXVAL
The maximum value that can be stored in the KyFloat32 variable type.
Definition: types.h:227
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
#define KY_NULL
Null value.
Definition: types.h:247
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
#define KyUInt16MAXVAL
The maximum value that can be stored in the KyUInt16 variable type.
Definition: types.h:230
unsigned short KyUInt16
Type used internally to represent an unsigned 16-bit integer.
Definition: types.h:40
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43