gwnavgeneration/generator/generatorparameters.h Source File

generatorparameters.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 
9 // primary contact: GUAL - secondary contact: LASI
10 #ifndef GwNavGen_GeneratorGlobalConfig_H
11 #define GwNavGen_GeneratorGlobalConfig_H
12 
13 
19 
20 namespace Kaim
21 {
22 
23 class BlobAggregate;
24 class DatabaseGenMetrics;
25 
26 class GeneratorNormalizedParameters
27 {
28  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
29 
30 public:
31  GeneratorNormalizedParameters();
32  void Clear();
33  bool IsValid() const;
34 
35 public:
36  KyFloat32 m_normalizedRasterPrecision; // NearestInt(GeneratorParameters::m_entityRadius / GeneratorParameters::m_rasterPrecision)
37  KyUInt32 m_cellSizeInPixel;
38  KyUInt32 m_entityRadiusInPixel;
39  KyUInt32 m_distanceFromWallsInPixel;
40  KyUInt32 m_distanceFromHolesInPixel;
41  KyFloat32 m_normalizedCellSize;
42  KyFloat32 m_normalizedEntityRadius;
43 };
44 
45 
46 class GeneratorParametersBlob
47 {
48  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
49  KY_ROOT_BLOB_CLASS(Generator, GeneratorParametersBlob, 0)
50  KY_CLASS_WITHOUT_COPY(GeneratorParametersBlob)
51 public:
52  GeneratorParametersBlob() {}
53  BlobFieldArray m_fields;
54  NavTag m_defaultNavTag;
55  VisualColor m_emptyDefaultNavTagColor;
56  VisualColor m_nonEmptyDefaultNavTagColor;
57  VisualColor m_nonDefaultNavTagColor;
58 };
59 inline void SwapEndianness(Endianness::Target e, GeneratorParametersBlob& self)
60 {
61  SwapEndianness(e, self.m_fields);
62  SwapEndianness(e, self.m_defaultNavTag);
63  SwapEndianness(e, self.m_emptyDefaultNavTagColor);
64  SwapEndianness(e, self.m_nonEmptyDefaultNavTagColor);
65  SwapEndianness(e, self.m_nonDefaultNavTagColor);
66 }
67 
68 
72 class GeneratorParameters
73 {
74  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
75 public:
76  // The binary backward compatibility of the GeneratorParameters blob is ensured by its nature (BlobFieldMapping)
77  // However, when a parameter is added or renamed its value will be set to the default value (from Ctor)
78  // when loading older versions of configs (from older clientInput).
79  // This behavior might have some random effects.
80  enum { Version = 1 };
81 
82 public:
84  void Clear();
85  void SetDefaultValues() { Clear(); }
86 
87  void ComputeNormalizedParams();
88 
89  // Helper function allowing to transform a genParams to its runtime equivalent
90  void ComputeDatabaseGenMetrics(DatabaseGenMetrics& genMetrics) const;
91 
93  void BuildBlob(BlobHandler<GeneratorParametersBlob>& handler) const;
94 
96  KyResult ReadFromBlobHandler(BlobHandler<GeneratorParametersBlob>& handler) { return ReadFromBlob(*handler.Blob()); }
97 
100  KyResult ReadFromAggregate(BlobAggregate& aggregate);
103  bool operator==(const GeneratorParameters& other) const;
104 
106  bool operator!=(const GeneratorParameters& other) const { return !operator==(other); }
107 
108  void InitBlobFieldMapping(BlobFieldsMapping& mapping, KyUInt32& version);
109  void InitBlobFieldMapping(BlobFieldsMapping& mapping, KyUInt32& version) const;
110 
113  KyResult ReadFromBlob(const GeneratorParametersBlob& blob);
114 
115  void SetDefaultNavTag(const KyArrayPOD<KyUInt32>& blindDataArray) { SetDefaultNavTag(blindDataArray.GetDataPtr(), blindDataArray.GetCount()); }
116  void SetDefaultNavTag(const KyUInt32* blindDataBuffer, KyUInt32 blindDataCount);
117  void SetEmptyDefaultNavTagColor(VisualColor color);
118  void SetNonEmptyDefaultNavTagColor(VisualColor color);
119  void SetNonDefaultNavTagColor(VisualColor color);
120 
121  const DynamicNavTag& GetDefaultNavTag() const { return m_defaultNavTag; }
122 
123 public:
127  KyFloat32 m_entityHeight;
128 
133  KyFloat32 m_entityRadius;
134 
138  KyFloat32 m_stepMax;
145  KyFloat32 m_slopeMax;
146 
153  KyFloat32 m_rasterPrecision;
154 
160  KyFloat32 m_cellSize;
165  KyFloat32 m_altitudeTolerance;
166 
169  GeneratorAdvancedParameters m_advancedParameters;
170 
171  // computed in ComputeNormalizedParams(), do not set directly
172  GeneratorNormalizedParameters m_normalizedParameters;
173 
174 private:
176  DynamicNavTag m_defaultNavTag;
177 };
179 
180 template <class OSTREAM>
181 inline OSTREAM& operator<<(OSTREAM& os, GeneratorParameters& params)
182 {
183  BlobFieldsMapping mapping;
184  KyUInt32 version = 0;
185  params.InitBlobFieldMapping(mapping, version);
187  os << KY_LOG_SMALL_TITLE_BEGIN("", "GeneratorParameters Info");
188  os << mapping;
189  // os << m_defaultNavTag;
190  os << KY_LOG_SMALL_TITLE_END("", "GeneratorParameters Info");
191  return os;
192 }
193 
194 
195 class GeneratorParametersBlobBuilder : public BaseBlobBuilder<GeneratorParametersBlob>
196 {
197 public:
198  GeneratorParametersBlobBuilder(const GeneratorParameters* params) : m_params(params) {}
199 
200 private:
201  virtual void DoBuild();
202 
203  const GeneratorParameters* m_params;
204 };
205 
206 } // namespace Kaim
207 
208 #endif
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
The BlobHandler class is a top-level mechanism for serializing blobs between objects in memory and fi...
Definition: blobhandler.h:45
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
This class provides information about Gameware Navigation version.
Definition: version.h:20
The GeneratorAdvancedParameters class is used by the GeneratorParameters class to maintain a set of c...
Definition: generatoradvancedparameters.h:34
Definition: gamekitcrowddispersion.h:20
The GeneratorParameters class contains configuration parameters that control the characteristics of t...
Definition: generatorparameters.h:75
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
BaseBlobBuilder is an abstract base class that builds a blob within a contiguous block of memory...
Definition: baseblobbuilder.h:30
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
This class gathers a set of generation parameters of one Database and manages the conversion between ...
Definition: databasegenmetrics.h:24
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43