gwnavgeneration/generator/generatorsector.h Source File

generatorsector.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 // primary contact: GUAL - secondary contact: LASI
8 #ifndef GwNavGen_GeneratorSector_H
9 #define GwNavGen_GeneratorSector_H
10 
19 
20 namespace Kaim
21 {
22 
23 class GeneratorSectorBlob;
24 class GeneratorFileSystem;
25 class BlobFieldsMapping;
26 
27 
29 class GeneratorSectorRefCountedUserData : public Kaim::RefCountBase<GeneratorSectorRefCountedUserData, Kaim::MemStat_NavDataGen>
30 {
31 public:
32  virtual const char* GetType() const = 0;
33 
34  bool Isa(const char* type) const { return SFstrcmp(GetType(), type) == 0; }
35 
37 };
38 
43 class GeneratorSector : public RefCountBaseNTS<GeneratorSector, MemStat_NavDataGen>
44 {
45  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
46 
47 friend class Generator;
48 friend class GeneratorSectorBuilder;
49 friend class GeneratorSectorBlobBuilder;
50 friend class GeneratorSectorListBlob;
51 
52 public:
53  GeneratorSector();
54  GeneratorSector(const KyGuid& sectorGuid, const char* sectorName);
55  void Clear();
56 
60  enum ClearPointedDataMode { CLEAR_NONE = 0, CLEAR_NAVDATA = 1, CLEAR_USERDATA = 2, CLEAR_ALL_POINTED_DATA = 3 };
61  void ClearPointedData(ClearPointedDataMode clearPointedDataMode);
62 
63 public:
64  const char* GetName() const { return m_sectorName.ToCStr(); }
65  const String& GetNameString() const { return m_sectorName; }
66 
67  const KyGuid& GetGuid() const { return m_sectorGuid; };
68  String GetGuidString() const;
69 
72 
73  void SetColDataBuildMode(GenFlags::SectorColDataBuildMode colDataBuildMode);
74  GenFlags::SectorColDataBuildMode GetColDataBuildMode() const;
75 
76  void AddInputFileName(const char* inputFileName) { m_inputFileNames.PushBack(String(inputFileName)); }
77 
78  void AddInputSeedPoint(const Vec3f& position) { m_inputSeedPoints.PushBack(position); }
79  void AddInputSeedPointInClientCoordinates(const Vec3f& client_position, const CoordSystem& coordSystem) { AddInputSeedPoint(coordSystem.ClientToNavigation_Pos(client_position)); }
80 
81  void AddInputTagVolume(const ClientInputTagVolume& clientInputTagVolume) { m_inputTagVolumes.PushBack(clientInputTagVolume); }
82 
83  bool IsNavDataCellBoxSet() const;
84 
85  String GetAbsoluteOutputFileName(const GeneratorFileSystem& fileSystem, const String& extension) const;
86  String GetRelativeOutputFileName(const GeneratorFileSystem& fileSystem, const String& extension) const;
87 
92  Ptr<NavData> GetNavData() { return m_navData; }
93 
96  Ptr<NavData> GetNavDataPatch() { return m_navDataPatch; }
97 
101  Ptr<CollisionData> GetColData() { return m_colData; }
104  KyResult SaveNavData(const char* filename, FileOpenerBase* fileOpener = KY_NULL, Endianness::Type endianness = Endianness::BigEndian);
105 
106 private:
107  void InitBlobFieldsMapping(BlobFieldsMapping& mapping);
108  void InitFromBlob(const GeneratorSectorBlob& blob);
109 
110 public:
111  // ---------- High level description of the sector, once these parameters has been set, they must not change. ----------
113  String m_sectorName;
115  bool m_isPatch;
116 
117  // ---------- How to produce the sector generation inputs. These parameters are mostly used in your implementation of GeneratorInputProducer::ProduceSectorInputs() ----------
118  // How to produce the inputs. Your derivation of GeneratorInputProducer passed to the Generator constructor has the responsibility to produce inputs.
119  // But the following parameters affect the process.
124  void* m_userData;
125  Ptr<GeneratorSectorRefCountedUserData> m_refCountedUserData;
127  // ---------- What has changed in the sector since previous generation ----------
129 
130  // ---------- Debug/Iterative file setup ----------
133 
134  // ---------- Generation Outputs ----------
139  Ptr<NavData> m_navData;
140  Ptr<NavData> m_navDataPatch;
141  Ptr<CollisionData> m_colData;
143  // ---------- Previous generation outputs, which are useful for iterative generations ----------
147 };
148 
150 inline String GeneratorSector::GetGuidString() const
151 {
152  char guidChars[37];
153  m_sectorGuid.ToString(guidChars);
154  return String(guidChars);
155 }
157 inline void GeneratorSector::SetSectorChange(GenFlags::SectorChange sectorChange) { m_sectorChange = sectorChange; }
159 inline bool GeneratorSector::IsNavDataCellBoxSet() const { return m_navDataCellBox.IsValid(); }
160 
161 inline void GeneratorSector::SetColDataBuildMode(GenFlags::SectorColDataBuildMode colDataBuildMode) { m_colDataBuildMode = colDataBuildMode; }
162 inline GenFlags::SectorColDataBuildMode GeneratorSector::GetColDataBuildMode() const { return (GenFlags::SectorColDataBuildMode)m_colDataBuildMode; }
163 
165 }
168 #endif
Ptr< GeneratorSectorRefCountedUserData > m_refCountedUserData
Allows to point to your own sector data. Typically to be used in GeneratorInputProducer::ProduceSecto...
Definition: generatorsector.h:142
Ptr< NavData > m_navDataPatch
Generated NavData. Relevant when m_isPatch=true and m_patchOperation!=PATCH_NO_CHANGE.
Definition: generatorsector.h:169
Ptr< CollisionData > m_colData
Will be accessible when generation is done through GetColData(). KY_NULL until then.
Definition: generatorsector.h:170
Ptr< CollisionData > GetColData()
Retrieve a pointer to the ColData that was generated for this sector, or KY_NULL if the ColData is no...
Definition: generatorsector.h:108
const char * GetName() const
Retrieves the name set for this sector as char*.
Definition: generatorsector.h:69
Base interface for a class that opens a file on disk.
Definition: fileopener.h:35
KyGuid m_sectorGuid
The sector GUID.
Definition: generatorsector.h:125
KyArray< ClientInputTagVolume > m_inputTagVolumes
Optional facility. Will be fed automatically to the Sector. Sometimes easier than producing TagVolume...
Definition: generatorsector.h:140
Ptr< NavData > GetNavData()
Retrieve a pointer to the NavData that was generated for this sector, or KY_NULL if the navdata is no...
Definition: generatorsector.h:98
String m_clientInputAbsoluteFileName
Indicates Set by the Generator when the ClientInput is saved.
Definition: generatorsector.h:164
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
bool m_isClientInputSaveEnabled
Indicates whether to save ClientInput file.
Definition: generatorsector.h:156
Maintains generation data for each sector.
Definition: generatorsectorbuilder.h:41
bool IsNavDataCellBoxSet() const
Determines whether or not a cellBox was set for this sector.
Definition: generatorsector.h:192
SectorColDataBuildMode
Describes whether or not CollisionData should be saved on a per-sector basis.
Definition: genflags.h:54
Ptr< NavData > m_navData
Generated NavData. Relevant when m_isPatch=false and m_buildMode=SECTOR_CHANGE.
Definition: generatorsector.h:168
Used to serialize GeneratorInputOutput.
Definition: generatorsectorconfigblob.h:61
KyArray< CellPos > m_previousPatchCellPosList
From previous generation, the list of CellPos that were impacted by the Patch inputs. Empty if m_isPatch is false or if the Patch is new.
Definition: generatorsector.h:177
The Generator is the principal class in the NavData generation system.
Definition: generator.h:61
#define KY_NULL
Null value.
Definition: types.h:247
Used to serialize GeneratorInputOutput. Corresponds to GeneratorSector.
Definition: generatorsectorconfigblob.h:29
void SetSectorChange(GenFlags::SectorChange sectorChange)
Write accessor for m_sectorChange.
Definition: generatorsector.h:190
GenFlags::SectorChange GetSectorChange() const
Read accessor for m_sectorChange.
Definition: generatorsector.h:191
bool m_isPatch
Indicates if the Sector is a Patch.
Definition: generatorsector.h:128
Big-endian format (used, for example, for PlayStation 3, Xbox 360).
Definition: endianness.h:31
KyArray< String > m_inputFileNames
Optional facility. To be used in GeneratorInputProducer::ProduceSectorInputs().
Definition: generatorsector.h:138
KyUInt32 m_colDataBuildMode
takes values from GenerationFlags::SectorColDataSaveMode
Definition: generatorsector.h:157
String m_sectorName
The sector Name.
Definition: generatorsector.h:126
KyResult SaveNavData(const char *filename, FileOpenerBase *fileOpener=0, Endianness::Type endianness=Endianness::BigEndian)
If NavData was generated, save it to the specified location.
String m_navDataAbsoluteFileName
Set by the Generator when the NavData is saved. Relevant when isPatch is false.
Definition: generatorsector.h:165
KyUInt32 m_inputSource
Indicates whether GeneratorInputProducer::ProduceSectorInputs() is called -or- the sector ClientInput...
Definition: generatorsector.h:137
SectorChange
Describes what the generation does about a sector.
Definition: genflags.h:28
The GeneratorSector class provides a definition for a single sector to be treated by the Generator...
Definition: generatorsector.h:46
Definition: gamekitcrowddispersion.h:20
The KyGuid class represents a globally unique ID.
Definition: kyguid.h:22
Base class for the optional m_refCountedUserData that allows to refCount your user data...
Definition: generatorsector.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
KyArray< Vec3f > m_previousSeedPoints
From previous generation, the sector SeedPoints.
Definition: generatorsector.h:179
void ToString(char guidString[]) const
Converts this GUID to a string.
Type
Enumerates possible endianness types.
Definition: endianness.h:28
String m_colDataAbsoluteFileName
Set by the Generator when the ColData is saved.
Definition: generatorsector.h:167
CellBox m_navDataCellBox
Optional, limits the NavData generation to this CellBox. Relevant when pipeline uses tiles as sectors...
Definition: generatorsector.h:127
String m_navDataPatchAbsoluteFileName
Set by the Generator when the NavDataPatch is saved.
Definition: generatorsector.h:166
used to serialize GeneratorInputOutput
Definition: generatorsectorlistblob.h:23
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
KyArray< Vec3f > m_inputSeedPoints
Optional facility. Will be fed automatically to the Sector. Sometimes easier than producing seedPoint...
Definition: generatorsector.h:139
bool IsValid() const
Indicates whether or not the extents of the bounding box are valid.
Definition: box2i.h:154
CellBox m_previousInputCellBox
From previous generation, the AABB of CellPos that were impacted by the Sector or Patch Inputs...
Definition: generatorsector.h:178
Ptr< NavData > GetNavDataPatch()
Retrieve a pointer to the NavDataPatch that was generated for this sector, or KY_NULL if the navDataP...
Definition: generatorsector.h:102
ClearPointedDataMode
Reset the GeneratorSector as if is was just default constructed.
Definition: generatorsector.h:64
const String & GetNameString() const
Retrieves the name set for this sector as String.
Definition: generatorsector.h:70
KyUInt32 m_sectorChange
What has changed in the sector since previous generation.
Definition: generatorsector.h:149
void * m_userData
Allows to point to your own sector data. Typically to be used in GeneratorInputProducer::ProduceSecto...
Definition: generatorsector.h:141
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23
String GetGuidString() const
Retrieves the GUID set for this sector.
Definition: generatorsector.h:183