gwnavgeneration/generator/generatorsectorbuilder.h Source File

generatorsectorbuilder.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 
24 #include "generatorsectorreport.h"
25 
26 namespace Kaim
27 {
28 
29 class NavCellGenerator;
30 class GeneratorSector;
31 class GeneratorNavDataElement;
32 class ClientInput;
33 class NavDataIndex;
34 class InputTileBlob;
35 class InputTileCache;
36 class SectorInputData;
37 
39 class GeneratorSectorBuilder : public Kaim::RefCountBaseNTS<GeneratorSectorBuilder, MemStat_NavDataGen>
40 {
41 public:
42  // determines whether or not the sector is overlapping another one
43  enum SectorOverlapStatus { SECTOR_IS_OVERLAPPING_ANOTHER_SECTOR = 0, SECTOR_IS_ISOLATED };
44 
45 public:
46  GeneratorSectorBuilder(GeneratorSystem* sys, Ptr<GeneratorSector> sector);
47 
49 
50 public:
51  String GetTileDirName();
52  String GetTileFileName(KyInt32 x, KyInt32 y);
53 
54  void ClearSectorInput();
55  void ClearNavDataElements();
56 
57  KyResult ProduceSectorInput(GeneratorInputProducer* producer);
58 
59  GeneratorNavDataElement* GetOrCreateNavDataElement(const GeneratorGuidCompound& guidCompound);
60 
61  KyResult GenerateRawNavCells(InputTileCache& inputTileCache);
62 
63  KyResult FilterCells();
64 
65  // Compute m_sector->m_navData from NavDataElements and m_sector->m_colData
66  KyResult MakeOutputBlobAggregates();
67 
68  const GeneratorNavDataElementMap& GetNavDataElements() const { return m_navDataElements; }
69 
70  const KyGuid& GetGuid() const { return m_sector->GetGuid(); }
71 
72  const char* GetName() const { return m_sector->GetName(); }
73 
74  void ComputeSectorBBox(Box2f& box);
75 
76  template<class OSTREAM> void LogConfiguration(OSTREAM& os);
77 
78  void ComputeStatistics();
79 
80 private:
81  KyResult BuildNavMeshElementBlobs();
82  KyResult MakeNavData();
83  KyResult MakeColData();
84  void Init();
85  void ComputeGenerationFlags();
86  KyResult SaveNavData(const String& navDataName, BlobAggregate* navData);
87  KyResult SaveColData(const String& colDataName, BlobAggregate* colData);
88  void ClearNavCellHandlers();
89  void ComputeSectorCellBox(Box2i& cellBox);
90 
91 public:
92  GeneratorSystem* m_sys;
93  Ptr<GeneratorSector> m_sector;
94 
95  // result of the input production
96  SectorInputData* m_sectorInput; // Triangles spatialized by cellPos
97  bool m_sectorInputWasProduced;
98  KyArray<CellPos> m_currentPatchCellPosList;
99  CellBox m_currentInputCellBox;
100  KyArray<Vec3f> m_currentSeedPoints;
101  KyArray<TagVolumeInitConfig> m_currentTagVolumeInitConfigs;
102 
103  IndexedMeshBlobBuilder m_inputMeshBuilder;
104  KyArray<Ptr<IndexedMesh> > m_indexedMeshes;
105  Ptr<HeightField> m_heightfield;
106  ClientInputConsumerStatistics m_clientInputConsumerStatistics;
107 
108  GeneratorNavDataElementMap m_navDataElements;
109 
110  bool m_doGenerateNavData;
111  bool m_doGenerateColData;
112 
113  GeneratorSectorReport m_sectorStatistics;
114 };
115 
116 template<class OSTREAM>
117 inline void GeneratorSectorBuilder::LogConfiguration(OSTREAM& os)
118 {
119  os << "sectorName : " << m_sector->GetName() << Endl;
120  os << "sectorGuidString : " << m_sector->GetGuidString().ToCStr() << Endl;
121 
122  switch (m_sector->GetSectorChange())
123  {
124  case GenFlags::SECTOR_CHANGED : os << "SectorChange : " << "SECTOR_CHANGED" << Endl; break;
125  case GenFlags::SECTOR_NOCHANGE: os << "SectorChange : " << "SECTOR_NOCHANGE" << Endl; break;
126  case GenFlags::SECTOR_REMOVED : os << "SectorChange : " << "SECTOR_REMOVED" << Endl; break;
127  }
128 
129  os << "doGenerateNavData : " << m_doGenerateNavData << Endl;
130  os << "doGenerateColData : " << m_doGenerateColData << Endl;
131 }
132 
133 } // namespace Kaim
134 
135 
Read previous imprint of the Sector, the difference is included in the generated NavDataPatch.
Definition: genflags.h:30
2d axis aligned box of 32bits floating points
Definition: box2f.h:15
2d axis aligned box of 32bits integers. Very Important: CountX() returns m_max.x - m_min...
Definition: box2i.h:17
Maintains generation data for each sector.
Definition: generatorsectorbuilder.h:39
GeneratorSystem gathers everything that is global across a generation: configuration, options...
Definition: generatorsystem.h:45
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:162
The SectorStatistics class encapsulates a detailed set of statistics about a single sector treated by...
Definition: generatorsectorreport.h:19
Maintains the InputCellBlobs spatialized per CellPos for 1 SectorInput.
Definition: sectorinputdata.h:43
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
The KyGuid class represents a globally unique ID.
Definition: kyguid.h:20
std::int32_t KyInt32
int32_t
Definition: types.h:24
The GeneratorInputProducer is an abstract base class for an object invoked by the NavData generation ...
Definition: generatorinputproducer.h:28
This class is a wrapper around an array of KyGuid objects.
Definition: generatorguidcompound.h:20
May load the Sector inputs (if required by other CHANGED Sectors), does NOT generate any NavData or N...
Definition: genflags.h:29
Load the Sector inputs, generate the Sector NavData or impact the NavDataPatch.
Definition: genflags.h:28