gwnavruntime/navmesh/dynamicnavcell.h Source File

dynamicnavcell.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 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 // Primary contact: JUBA - secondary contact: LASI
12 #ifndef Navigation_DynamicNavCell_H
13 #define Navigation_DynamicNavCell_H
14 
17 
18 namespace Kaim
19 {
20 
21 
22 struct DynamicCellBoundaryFloor
23 {
24  KyUInt32 m_floorIdx;
25 };
26 
27 struct DynamicCellBoundaryEdge
28 {
29  KyUInt32 m_halfEdgeIdx;
30 };
31 
32 struct DynamicCellBoundaryEdgesInFloor
33 {
34  DynamicCellBoundaryEdgesInFloor() : m_cellBoundaryEdges(KY_NULL) {}
35  DynamicCellBoundaryEdgesInFloor(MemoryHeap* heap) : m_cellBoundaryEdges(heap)
36  {
37  for (KyUInt32 i = 0; i < 4; ++i)
38  m_cellBoundaryEdges.PushBack(ArrayDH<DynamicCellBoundaryEdge>(heap));
39  }
40  ArrayDH<ArrayDH<DynamicCellBoundaryEdge> > m_cellBoundaryEdges;// one vector per Direction : CardinalDir_EST, CardinalDir_NORTH, CardinalDir_WEST, CardinalDir_SOUTH
41 };
42 
43 // --------------------------
44 // ----- DynamicNavCell -----
45 // --------------------------
46 class DynamicNavCell
47 {
48  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
49 
50 public:
51  DynamicNavCell(MemoryHeap* heap, const CellDesc& cellDesc)
52  : m_cellDesc(cellDesc)
53  , m_floors(heap)
54  {}
55 
56  void Clear()
57  {
58  for (KyUInt32 i = 0; i < m_floors.GetCount(); ++i)
59  m_floors[i].Clear();
60  }
61 
62  CardinalDir GetBoundaryDir(const PixelPos& start, const PixelPos& end) const;
63 
64  bool AreIndexesWithinBounds() const
65  {
66  // Check indexes inside of each floor
67  for (KyUInt32 floorIdx = 0; floorIdx < m_floors.GetCount(); ++floorIdx)
68  {
69  if (!m_floors[floorIdx].AreIndexesWithinBounds())
70  {
71  return false;
72  }
73  }
74 
75  return true;
76  }
77 
78  bool IsEmpty()
79  {
80  if (m_floors.IsEmpty())
81  return true;
82 
83  for (KyUInt32 i = 0; i < m_floors.GetCount(); ++i)
84  {
85  const DynamicNavFloor& floor = m_floors[i];
86  if (floor.m_edges.IsEmpty() == false || floor.m_triangles.IsEmpty() == false )
87  return false;
88  }
89 
90  return true;
91  }
92 
93 public:
94  CellDesc m_cellDesc;
95  KyArrayDH<DynamicNavFloor> m_floors;
96 };
97 
98 }
99 
100 
101 #endif //Navigation_DynamicNavCell_H
102 
#define KY_NULL
Null value.
Definition: types.h:247
KyUInt32 CardinalDir
Defines a type that refers to one of the cardinal points on the compass:
Definition: cardinaldir.h:23
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36