gwnavgeneration/input/inputcellinfo.h Source File

inputcellinfo.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 // primary contact: GUAL - secondary contact: NOBODY
9 #ifndef GwNavGen_InputCellInfo_H
10 #define GwNavGen_InputCellInfo_H
11 
12 
17 
18 
19 namespace Kaim
20 {
21 
22 class InputCellBlob;
23 class GeneratorSectorBuilder;
24 
25 
26 // Small wrapper around m_inputCellBlobHandler that can be NULL.
27 // Allows to retrieve sectorBuilder from which the m_inputCellBlobHandler comes from.
28 // Allows to retrieve cellPos even when m_inputCellBlobHandler is KY_NULL (when IsInputTilingEnabled() is true).
29 class InputCellInfo
30 {
31  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavDataGen)
32 
33 public:
34  InputCellInfo() // default Ctor for KyArray<InputCellInfo>
35  : m_sectorBuilder(KY_NULL)
36  {}
37 
38  InputCellInfo(GeneratorSectorBuilder* sectorBuilder, const CellPos& cellpos, Ptr<BlobHandler<InputCellBlob> > inputCellBlobHandler)
39  : m_sectorBuilder(sectorBuilder), m_cellPos(cellpos), m_inputCellBlobHandler(inputCellBlobHandler)
40  {}
41 
42  bool operator==(const InputCellInfo& other) const
43  {
44  return m_sectorBuilder == other.m_sectorBuilder
45  && m_cellPos == other.m_cellPos;
46  // we do not compare m_inputCellBlob on purpose because m_inputCellBlobHandler may be in memory (!= KY_NULL) or not (== KY_NULL)
47  }
48 
49  bool operator!=(const InputCellInfo& other) const { return !operator==(other); }
50 
51 public:
52  GeneratorSectorBuilder* m_sectorBuilder; // the sector(Builder) from which the InputCell comes from
53  CellPos m_cellPos;
54  Ptr<BlobHandler<InputCellBlob> > m_inputCellBlobHandler; // NULL is sys->InputTilingEnabled()
55 };
56 
57 
58 class InputCellInfoArrayAtPos : public RefCountBaseNTS<InputCellInfoArrayAtPos, MemStat_NavDataGen>
59 {
60 public:
61  InputCellInfoArrayAtPos(KyInt32 x, KyInt32 y) : m_cellPos(x, y) {}
62 
63  void PushBack(const InputCellInfo& inputCellInfo) { m_inputCellInfos.PushBack(inputCellInfo); }
64 
65  KyUInt32 GetCount() const { return m_inputCellInfos.GetCount(); }
66 
67  const InputCellInfo& Get(KyUInt32 index) const { return m_inputCellInfos[index]; }
68  InputCellInfo& Get(KyUInt32 index) { return m_inputCellInfos[index]; }
69 
70  bool DoesContain(const InputCellInfo& inputCellInfo) { return m_inputCellInfos.DoesContain(inputCellInfo); }
71 
72  // m_inputCells from sectors with m_doGenerateNavData==true are at the beginning of the m_inputCellInfos
73  void Sort();
74 
75 public:
76  CellPos m_cellPos;
77  KyArray<InputCellInfo> m_inputCellInfos;
78 };
79 
80 
81 } // namespace Kaim
82 
83 #endif
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:33
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
#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
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36