gwnavgeneration/generator/generatorsectorbuilder.h Source File

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