gwnavgeneration/generator/generatornavdataelement.h Source File

generatornavdataelement.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 
19 
20 
21 namespace Kaim
22 {
23 
24 class GeneratorSystem;
25 class CellGenerator;
26 class NavMeshElementBlob;
27 class GeneratorSectorBuilder;
28 
29 
30 
31 // GeneratorNavDataElement corresponds either to a "pure" NavMesh or to an "overlap" NavMesh
32 // GeneratorSector (1 GUID) <-> NavData
33 // +- 1 mandatory pure (GuidCompound = 1 GUID) GeneratorNavDataElement <-> +- 1 mandatory pure (GuidCompound = 1 GUID) NavMeshElementBlob
34 // +- N optional overlap (GuidCompound = X>1 GUID) GeneratorNavDataElement <-> +- N optional overlap (GuidCompound = X>1 GUID) NavMeshElementBlob
35 class GeneratorNavDataElement
36 {
37  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavDataGen)
38 
39 public:
40  GeneratorNavDataElement(GeneratorSystem* sys)
41  : m_sys(sys)
42  , m_mainSectorBuilder(nullptr)
43  , m_emptyNavCellMode(KEEP_EMPTY_NAVCELL)
44  {}
45 
46  // if InputTiling is enabled this function will delete inputCellInfoArrayAtPos adn set it to NULL
47  void SetContributingInputCellInfoArrayAtPos(const Ptr<InputCellInfoArrayAtPos>& inputCellInfoArrayAtPos);
48 
49  KyResult GenerateRawNavCells(InputTileCache& inputTileCache);
50 
51  // Seed or Small Surface Filtering
52  KyResult FilterNavCells();
53 
54  // Replace some NavCellBlobs in m_navCellHandlers
55  // Uses m_navMeshElementHandler temporarily
56  KyResult IntegrateTagVolumes();
57 
58  // KEEP_EMPTY_NAVCELL is useful to keep 1to1 mapping with m_outputNavCells
59  // DISCARD_EMPTY_NAVCELL is useful when building the final NavData blobs
60  enum EmptyNavCellMode { KEEP_EMPTY_NAVCELL, DISCARD_EMPTY_NAVCELL};
61 
62  // Build m_navMeshElementHandler from m_navCellHandlers
63  KyResult BuildNavMeshElementBlob(EmptyNavCellMode emptyNavCellMode);
64 
65  // Helper getter
66  NavMeshElementBlob* GetNavMeshElementBlob() { return m_navMeshElementHandler ? m_navMeshElementHandler->Blob() : nullptr; }
67 
68  // Used in IntegrateTagVolumes and FilterNavCells
69  void ReplaceNavCell(KyUInt32 navCellIndex, Ptr<BlobHandler<NavCellBlob> > navCellHandler);
70 
71  // Clear m_navCellHandlers
72  // Called when the final (filtered) m_navMeshElementHandler has been initialized
73  void ClearNavCellHandlers();
74 
75  // Used in GeneratorNavDataElementMap (that uses a binary tree internally)
76  // Compares m_guidCompound
77  bool operator<(const GeneratorNavDataElement& other) const { return m_guidCompound < other.m_guidCompound; }
78 
79 private:
80  KyResult ProcessCellGenerators(KyArray<CellGenerator*>& cellGenerators);
81  KyResult GenerateRawNavCells_NoTiling();
82  KyResult GenerateRawNavCells_WithTiling(InputTileCache& inputTileCache);
83 
84 public:
85  GeneratorSystem* m_sys;
86  GeneratorGuidCompound m_guidCompound;
87  GeneratorSectorBuilder* m_mainSectorBuilder;
88 
89  // -------------- inputs fed by AddInputCellInfosAtPos --------------
90  KyArray<Ptr<InputCellInfoArrayAtPos> > m_inputCellInfoArrayAtPosArray; // if InputTiling is disabled
91  DenseGridAndArrayOfRawPtr<InputTileContributionAtPos> m_inputTileGrid; // if InputTiling is enabled
92 
93  // ----------------------- intermediate outputs -----------------------
94  // m_navCellHandlers.GetCount() == m_navMeshElementHandler->GetCount() as long as
95  // BuildNavMeshElementBlob(KEEP_EMPTY_NAVCELL) was called
96  // Even if NavCell is empty, we garantee that all m_navCellHandlers[i].m_navCellHandler != nullptr && m_navCellHandlers[i].m_navCellHandler->Blob() != nullptr
97  KyArray<Ptr<BlobHandler<NavCellBlob> > > m_navCellHandlers;
98  EmptyNavCellMode m_emptyNavCellMode;
99 
100  // ---- final outputs: NavCellBlobs aggregated in NavMeshElementBlobs -----
101  // m_navMeshElementHandler is also used temporarily in FilterNavCells() and IntegrateTagVolumes()
102  Ptr<BlobHandler<NavMeshElementBlob> > m_navMeshElementHandler;
103 };
104 
105 }
106 
107 
108 
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