gwnavgeneration/generator/generatornavdataelement.h Source File

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