gwnavruntime/navmesh/dynamicnavcell.h Source File

dynamicnavcell.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 
9 
10 
11 #pragma once
12 
15 
16 namespace Kaim
17 {
18 
19 
20 struct DynamicCellBoundaryFloor
21 {
22  KyUInt32 m_floorIdx;
23 };
24 
25 struct DynamicCellBoundaryEdge
26 {
27  KyUInt32 m_halfEdgeIdx;
28 };
29 
30 struct DynamicCellBoundaryEdgesInFloor
31 {
32  DynamicCellBoundaryEdgesInFloor() : m_cellBoundaryEdges(nullptr) {}
33  DynamicCellBoundaryEdgesInFloor(MemoryHeap* heap) : m_cellBoundaryEdges(heap)
34  {
35  for (KyUInt32 i = 0; i < 4; ++i)
36  m_cellBoundaryEdges.PushBack(ArrayDH<DynamicCellBoundaryEdge>(heap));
37  }
38  ArrayDH<ArrayDH<DynamicCellBoundaryEdge> > m_cellBoundaryEdges;// one vector per Direction : CardinalDir_EST, CardinalDir_NORTH, CardinalDir_WEST, CardinalDir_SOUTH
39 };
40 
41 // --------------------------
42 // ----- DynamicNavCell -----
43 // --------------------------
44 class DynamicNavCell
45 {
46  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
47 
48 public:
49  DynamicNavCell(MemoryHeap* heap, const CellDesc& cellDesc)
50  : m_cellDesc(cellDesc)
51  , m_floors(heap)
52  {}
53 
54  void Clear()
55  {
56  for (KyUInt32 i = 0; i < m_floors.GetCount(); ++i)
57  m_floors[i].Clear();
58  }
59 
60  CardinalDir GetBoundaryDir(const PixelPos& start, const PixelPos& end) const;
61 
62  bool AreIndexesWithinBounds() const
63  {
64  // Check indexes inside of each floor
65  for (KyUInt32 floorIdx = 0; floorIdx < m_floors.GetCount(); ++floorIdx)
66  {
67  if (!m_floors[floorIdx].AreIndexesWithinBounds())
68  {
69  return false;
70  }
71  }
72 
73  return true;
74  }
75 
76  bool IsEmpty()
77  {
78  if (m_floors.IsEmpty())
79  return true;
80 
81  for (KyUInt32 i = 0; i < m_floors.GetCount(); ++i)
82  {
83  const DynamicNavFloor& floor = m_floors[i];
84  if (floor.m_edges.IsEmpty() == false || floor.m_triangles.IsEmpty() == false )
85  return false;
86  }
87 
88  return true;
89  }
90 
91 public:
92  CellDesc m_cellDesc;
93  KyArrayDH<DynamicNavFloor> m_floors;
94 };
95 
96 }
97 
98 
99 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
KyUInt32 CardinalDir
Defines a type that refers to one of the cardinal points on the compass:
Definition: cardinaldir.h:15
#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