gwnavgeneration/input/clientinputconsumer.h Source File

clientinputconsumer.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: LASI
9 #ifndef GwNavGen_ClientInputConsumer_H
10 #define GwNavGen_ClientInputConsumer_H
11 
20 
21 namespace Kaim
22 {
23 
24 class GeneratorSystem;
25 class SpatializedSectorInput;
26 class SectorInputData;
27 class GeneratorSector;
28 class GeneratorInputProducer;
29 
30 
31 // interesting statistics, can be used to check if there was a OneMeter problem
32 class ClientInputConsumerStatistics
33 {
34  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
35 public:
36  ClientInputConsumerStatistics() { Clear(); }
37 
38  void Clear()
39  {
40  m_nbConsumedTriangles = 0;
41  m_consumedSurface2d = 0;
42  m_nbConsumedVolumes = 0;
43  }
44 
45  KyUInt32 GetNbConsumedTriangles() { return m_nbConsumedTriangles; }
46  KyFloat32 GetConsumedSurface2d() { return m_consumedSurface2d; }
47  KyFloat32 GetAverageConsumedTriangleSurface2d() { return m_consumedSurface2d / (KyFloat32)m_nbConsumedTriangles; }
48  void GetConsumedTrianglesBoundingBox(Box3f& box) { box = m_consumedTrianglesBoundingBox; }
49 
50 public:
51  KyInt32 m_nbConsumedTriangles;
52  KyFloat32 m_consumedSurface2d;
53  Box3f m_consumedTrianglesBoundingBox;
54  KyUInt32 m_nbConsumedVolumes;
55 };
56 
64 class ClientInputConsumer
65 {
66  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
67  friend class GeneratorSectorBuilder;
68  friend class SectorInputData;
69 
70 public:
71  // ClientInputConsumer will initialize
72  // seedPoints with what is passed to ConsumeSeedPoint()
73  // inputMeshBuilder with what is passed to ConsumeTriangle...()
74  // indexedMeshes with what is passed to ConsumeIndexedMesh()
75  // heightfield with what is passed to ConsumeHeightfield()
76  ClientInputConsumer(GeneratorSystem* sys, Ptr<GeneratorSector> sector, KyArray<Vec3f>* seedPoints, KyArray<TagVolumeInitConfig>* tagVolumeConfigs,
77  IndexedMeshBlobBuilder* inputMeshBuilder, KyArray<Ptr<IndexedMesh> >* indexedMeshes, Ptr<HeightField>* heightfield);
78 
80 
81 public:
82  // ---------------------------------- Consumption ----------------------------------
83 
85  KyResult ConsumeTriangle(const Vec3f& A, const Vec3f& B, const Vec3f& C);
86 
88  KyResult ConsumeTriangle(const Vec3f& client_A, const Vec3f& client_B, const Vec3f& client_C, const CoordSystem& clientCoordSystem);
89 
91  KyResult ConsumeTriangle(const Vec3f& A, const Vec3f& B, const Vec3f& C, const DynamicNavTag& navTag);
92 
95  const Vec3f& client_A, const Vec3f& client_B, const Vec3f& client_C, const DynamicNavTag& navTag, const CoordSystem& clientCoordSystem);
96 
99  KyResult ConsumeTagVolume(const ClientInputTagVolume& inputTagVolume);
100 
106  KyResult ConsumeSeedPoint(const Vec3f& position);
107 
109  KyResult ConsumeSeedPointInClientCoordinates(const Vec3f& client_position, const CoordSystem& clientCoordSystem) { return ConsumeSeedPoint(clientCoordSystem.ClientToNavigation_Pos(client_position)); }
110 
111  KyResult ConsumeHeightField(Ptr<HeightField> heightfield);
112  KyResult ConsumeHeightFieldFile(const String& heightfieldFileName);
113 
114  KyResult ConsumeIndexedMesh(Ptr<IndexedMesh> indexedMesh);
115  KyResult ConsumeIndexedMeshFile(const String& indexedMeshFileName);
117  ClientInputConsumerStatistics& GetStats() { return m_stats; }
118 
119  VisualColor GetNavTagColor(const DynamicNavTag& dynamicNavTag) const;
120 public : // Deprecated:
121  KY_DEPRECATED(VisualColor GetNavTagVisualColor(const DynamicNavTag& dynamicNavTag) const) { return GetNavTagColor(dynamicNavTag); }
122 
123 private:
125  void Flush();
126  KyResult SaveClientInput(const String& fullFileName);
127  KyResult FlushClientInput();
128  void TestWarningOnLowMemoryModeNbTriangles();
129  bool IsTriangleSlopeWalkable(const Vec3f& A, const Vec3f& B, const Vec3f& C);
130 
131 public:
132  ClientInputConsumerStatistics m_stats;
134 
135 private: // ---------------------------------- Internal ----------------------------------
136  Ptr<GeneratorSector> m_sector;
137 
138  // computed (or read) directly from m_sys->m_genIO->m_params
139  DynamicNavTag m_defaultNavTag;
142 
143  DynamicClientInputChunk m_dynamicClientInputChunk;
145 
147  KyUInt32 m_warnOnLowMemoryModeNbTriangles;
148 
149  SpatializedSectorInput* m_spatializedSectorInput;
151  KyArray<TagVolumeInitConfig>* m_tagVolumeConfigs;
152 
156  IndexedMeshBlobBuilder* m_inputMeshBuilder;
158  Ptr<HeightField>* m_heightfield;
159 };
161 
163 inline KyResult ClientInputConsumer::ConsumeTriangle(const Vec3f& A, const Vec3f& B, const Vec3f& C)
164 {
166 }
167 
168 inline KyResult ClientInputConsumer::ConsumeTriangle(const Vec3f& client_A, const Vec3f& client_B, const Vec3f& client_C, const CoordSystem& clientCoordSystem)
169 {
170  return ConsumeTriangle(client_A, client_B, client_C, m_defaultNavTag, clientCoordSystem);
171 }
174 }
175 
177 #endif
178 
void Flush()
internal usage by GeneratorSectorBuilder
Class used to provide TagVolume initialization parameters.
Definition: tagvolume.h:36
ClientInputConsumerStatistics m_stats
Maintains statistics about the data added to this object. Do not modify.
Definition: clientinputconsumer.h:146
KyUInt32 m_maxTriangleCountBeforeFlush
Internal member: For limited memory mode. 1024*1024 by default.
Definition: clientinputconsumer.h:165
The ClientInputConsumer class is one of the primary components of the NavData generation system...
Definition: clientinputconsumer.h:67
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
KyArray< Ptr< IndexedMesh > > * m_indexedMeshes
Internal member: Consumed IndexedMesh in Gameware Navigation coordinates.
Definition: clientinputconsumer.h:176
Maintains generation data for each sector.
Definition: generatorsectorbuilder.h:41
KyUInt32 m_clientInputFlushCount
Internal member: Count how many times the ClientInput was flushed.
Definition: clientinputconsumer.h:163
GeneratorSystem gathers everything that is global across a generation: configuration, options...
Definition: generatorsystem.h:46
The IndexedMesh class represents a 3D Triangle Mesh with Indexing.
Definition: indexedmesh.h:24
This class maintains the mapping between the system of coordinate axes used internally within the gam...
Definition: coordsystem.h:144
Ptr< HeightField > * m_heightfield
Internal member: Consumed heightField in Gameware Navigation coordinates.
Definition: clientinputconsumer.h:177
bool m_backFaceTrianglesWalkable
Internal member: Accessed using ToggleBackfaceTriangleFiltering.
Definition: clientinputconsumer.h:159
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
ClientInputConsumerStatistics & GetStats()
Retrieves information about the triangles consumed by this object.
Definition: clientinputconsumer.h:128
KyResult ConsumeTagVolume(const ClientInputTagVolume &inputTagVolume)
Provides a single tag volume to the ClientInputConsumer.
SpatializedSectorInput * m_spatializedSectorInput
Internal member: Spatialized input in Gameware Navigation coordinates.
Definition: clientinputconsumer.h:168
Represents a single RGBA color.
Definition: visualcolor.h:19
KyResult ConsumeSeedPoint(const Vec3f &position)
Provides a seed point that identifies a walkable area of the terrain.
Maintains the InputCellBlobs spatialized per CellPos for 1 SectorInput.
Definition: sectorinputdata.h:49
KyResult ConsumeSeedPointInClientCoordinates(const Vec3f &client_position, const CoordSystem &clientCoordSystem)
Identical to previous function but uses vertices in client coordinate system that must be specified i...
Definition: clientinputconsumer.h:120
DynamicClientInputChunk m_dynamicClientInputChunk
Internal member: Original input chunk.
Definition: clientinputconsumer.h:162
KyFloat32 m_cosSlopeMax
Internal member: cosinus of maximum slope.
Definition: clientinputconsumer.h:160
Heightfield with a uniform grid of sampled altitudes.
Definition: heightfield.h:51
The GeneratorSector class provides a definition for a single sector to be treated by the Generator...
Definition: generatorsector.h:46
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
#define KY_DEPRECATED(f)
Macro to mark a function, class or method as deprecated.
Definition: types.h:289
GeneratorSystem * m_sys
Fast access to the Generator-related information.
Definition: clientinputconsumer.h:147
DynamicNavTag m_defaultNavTag
shortcut for m_sys m_genParams.m_defaultNavTag;
Definition: clientinputconsumer.h:158
KyArray< Vec3f > m_inputTriangles
Temporary buffer for triangles - in Gameware Navigation coordinates.
Definition: clientinputconsumer.h:172
Ptr< GeneratorSector > m_sector
Internal member: The sector being processed.
Definition: clientinputconsumer.h:155
KyArray< Vec3f > * m_seedPoints
Internal member: Consumed seedpoints in Gameware Navigation coordinates.
Definition: clientinputconsumer.h:169
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
KyResult ConsumeTriangle(const Vec3f &A, const Vec3f &B, const Vec3f &C)
A, B and C are in Gameware Navigation coordinate system. m_defaultNavTag is used. ...
Definition: clientinputconsumer.h:182
Represents a volume using a two-dimensional polyline extruded vertically along the "up" axis associat...
Definition: clientinputtagvolume.h:30
KyArray< Vec3f > m_childrenTriangles
Temporary buffer for triangles - in Gameware Navigation coordinates.
Definition: clientinputconsumer.h:173
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23