gwnavgeneration/input/inputcellinfo.h Source File

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