gwnavruntime/queries/utils/spatializedpointcollectorcontext.h Source File

spatializedpointcollectorcontext.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 
8 #pragma once
9 
13 
14 namespace Kaim
15 {
16 
17 class ActiveData;
18 class WorkingMemory;
19 
20 class CollectorTraversalNodeIdx
21 {
22 public:
23  CollectorTraversalNodeIdx() : m_data(KyUInt32MAXVAL) {}
24  CollectorTraversalNodeIdx(const NavFloorRawPtr& /*navFloorRawPtr*/, KyUInt32 nodeIndex) : m_data(0x80000000 | nodeIndex) {}
25  CollectorTraversalNodeIdx(const NavGraphEdgeRawPtr& /*navGraphEdgeRawPtr*/, KyUInt32 nodeIndex) : m_data(0x7FFFFFFF & nodeIndex) {}
26 
27  KY_INLINE bool IsNavFloorNode() const { return (m_data & 0x80000000) != 0; }
28  KY_INLINE bool IsNavGraphEdgeNode() const { return (m_data & 0x80000000) == 0; }
29  KY_INLINE KyUInt32 GetNodeIndex() const { return (m_data & 0x7FFFFFFF); }
30 
31  KyUInt32 m_data; // 1 bit for type, 31 bit for index
32 };
33 
34 class SpatializedPointCollectorContext
35 {
36  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_QueryWorkingMem)
37 public:
38  SpatializedPointCollectorContext() {}
39  ~SpatializedPointCollectorContext() { ReleaseWorkingMemory(); }
40 
41  KyResult Init(WorkingMemory* workingMemory, ActiveData* activeData, const CellBox& cellBox);
42 
43  void ReleaseWorkingMemory()
44  {
45  m_traversalNodeStatus.ReleaseWorkingMemoryBuffer();
46  m_openNodes.ReleaseWorkingMemoryBuffer();
47  m_edgeRawPtrNodes.ReleaseWorkingMemoryBuffer();
48  m_navFloorRawPtrNodes.ReleaseWorkingMemoryBuffer();
49  }
50 public:
51  NavFloorAndNavGraphEdgeStatusInGrid m_traversalNodeStatus;
52  WorkingMemDeque<CollectorTraversalNodeIdx> m_openNodes; //< open nodes = nodes that are about to be analysed
53  WorkingMemArray<NavGraphEdgeRawPtr> m_edgeRawPtrNodes;
54  WorkingMemArray<NavFloorRawPtr> m_navFloorRawPtrNodes;
55  CellBox m_cellBox;
56 };
57 
58 
59 
60 
61 }
62 
63 
64 
Box2i CellBox
A type that represents a bounding box around cells in a 2D grid.
Definition: navmeshtypes.h:31
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
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
#define KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68