gwnavruntime/world/tagvolume.h Source File

tagvolume.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: LAPA - secondary contact: LASI
10 #ifndef Navigation_TagVolume_H
11 #define Navigation_TagVolume_H
12 
17 
18 
19 namespace Kaim
20 {
21 
22 class TagVolumeBlob;
23 class BoxObstacle;
24 class CylinderObstacle;
25 class VisualColor;
26 
27 
29 {
33 };
34 
37 {
38 public:
39 
40  // ---------------------------------- Main API Functions ----------------------------------
41 
43 
45  void SetDefaults()
46  {
47  m_points.Clear();
48  m_navTag.Clear();
49  m_world = KY_NULL;
51  m_altitudeMin = 0.0f;
52  m_altitudeMax = 0.0f;
54  }
55 
56  // ---------------------------------- Initialization ----------------------------------
57 
58  void SetContour(const Vec2f* points, KyUInt32 pointCount);
59  void InitFromTagVolumeBlob(const TagVolumeBlob& blob);
60  void Init4PointsContour(const Vec2f& center, const Vec2f& v1, const Vec2f& v2);
61  void Init6PointsContour(const Vec2f& center, const Vec2f& v1, const Vec2f& v2, const Vec2f& v3);
62  void InitFromBox(const Transform& transform, const Vec3f& localCenter, const Vec3f& localHalfExtents, DatabaseBinding* databaseBinding);
63 
64 public:
65  // ---------------------------------- Public Data Members ----------------------------------
66 
68  World* m_world;
69 
73  Ptr<DatabaseBinding> m_databaseBinding;
74 
77  DynamicNavTag m_navTag;
78 
80  KyFloat32 m_altitudeMin;
81  KyFloat32 m_altitudeMax;
82  TagVolumeExtendOptions m_extendOptions;
83 };
84 
85 
93 class TagVolume: public WorldElement
94 {
95  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_TagVolume)
97 
98 public:
99  enum WorldStatus
100  {
101  WorldStatus_NotInit = 0,
102  WorldStatus_Added,
103  WorldStatus_NotAdded,
104  WorldStatus_Unknown
105  };
106 
107  enum IntegrationStatus
108  {
109  IntegrationStatus_NotIntegrated = 0,
110  IntegrationStatus_ToBeIntegrated,
111  IntegrationStatus_IntegrationInProcess,
112  IntegrationStatus_Integrated,
113  IntegrationStatus_ToBeDeintegrated,
114  IntegrationStatus_DeintegrationInProcess
115  };
116 
117  enum ObstacleType
118  {
119  ObstacleType_Undefined = 0,
120  ObstacleType_BoxObstacle,
121  ObstacleType_CylinderObstacle
122  };
123 
124 public:
125  static WorldElementType GetStaticType() { return TypeTagVolume; }
126  virtual WorldElementType GetType() const { return TypeTagVolume; }
127 
128  virtual const char* GetTypeName() const { return "TagVolume"; }
129 
130  static const char* GetWorldStatusDescription(WorldStatus status);
131  static const char* GetIntegrationStatusDescription(IntegrationStatus status);
132  static const char* GetObstacleTypeName(ObstacleType obstacleType);
133 
134  TagVolume();
135  ~TagVolume();
136 
143  KyResult Init(const TagVolumeInitConfig& initConfig);
144 
152  void AddToWorld();
153 
159  void RemoveFromWorld();
160 
161 
162  // ---------------------------------- Getters ----------------------------------
163 
164  const Box3f& GetAABB() const;
165  KyFloat32 GetAltitudeMin() const;
166  KyFloat32 GetAltitudeMax() const;
167  KyUInt32 GetPointCount() const;
168  const Vec2f* GetPoints() const;
169  const Vec2f& GetPoint(KyUInt32 i) const;
170  const DynamicNavTag& GetNavTag() const;
171  WorldStatus GetWorldStatus() const;
172  IntegrationStatus GetIntegrationStatus() const;
173  ObstacleType GetObstacleType() const;
174  void* GetObstacleRawPtr() const;
175  BoxObstacle* GetBoxObstacle() const;
176  CylinderObstacle* GetCylinderObstacle() const;
177  const DatabaseBinding* GetDatabaseBinding() const;
178  TagVolumeExtendOptions GetTagVolumeExtendOptions() const;
179 
180 public: // internal
181  virtual void DoSendVisualDebug(VisualDebugServer& server, VisualDebugSendChangeEvent changeEvent); // Inherited from WorldElement
182  void SetObstacle(BoxObstacle* obstacle);
183  void SetObstacle(CylinderObstacle* obstacle);
184  void ResetObstacle();
185 
186  void OnIntegrationStart();
187  void OnDeIntegrationStart();
188 
189  void OnIntegrationDone();
190  void OnDeIntegrationDone();
191 
192  void OnIntegrationCancelled();
193  void OnDeIntegrationCancelled();
194 
195  const TagVolumeDatabaseData& GetTagVolumeDatabaseData() const { return m_tagVolumeDatabaseData; }
196  TagVolumeDatabaseData& GetTagVolumeDatabaseData() { return m_tagVolumeDatabaseData; }
197 
198  KyResult GetExpandedContour(KyFloat32 radius, KyFloat32 mergePointDistance, KyArray<Vec2f>& expandedContour) const;
199 
200  // WARNING Very internal. Used only internally during the generation process
201  void SetWorld(World* world);
202 private:
203  void PushPolylineFromInitConfigAccordingToWinding(const TagVolumeInitConfig& initConfig);
204  // AABB & point array are private to force PushPoint(...) usage to ensure coherency.
205  // AABB, point array and NavTag are private to trigger an update when modified.
206  // TagVolumeSpatialization is private to force read-only access.
207  Box3f m_aabb;
208  KyArray<Vec2f, MemStat_TagVolume> m_points;
209  DynamicNavTag m_navTag;
210 
211  TagVolumeDatabaseData m_tagVolumeDatabaseData;
212  TagVolumeExtendOptions m_extendOptions;
213 
214  ObstacleType m_obstacleType;
215  void* m_obstacleRawPtr;
216  TagVolumeCylinderExpander m_cylinderExpander;
217  TagVolumeBoxExpander m_boxExpander;
218 
219 public: // For internal use only
220  WorldStatus m_currentWorldStatus;
221  WorldStatus m_nextWorldStatus;
222  IntegrationStatus m_integrationStatus;
223 
224  // visual debug
225  bool m_needToSendNewContextBlob;
226  bool m_needToSendTagVolumeBlob;
227 };
228 
229 
230 KY_INLINE const Box3f& TagVolume::GetAABB() const { return m_aabb; }
231 KY_INLINE KyFloat32 TagVolume::GetAltitudeMin() const { return m_aabb.m_min.z; }
232 KY_INLINE KyFloat32 TagVolume::GetAltitudeMax() const { return m_aabb.m_max.z; }
233 KY_INLINE KyUInt32 TagVolume::GetPointCount() const { return m_points.GetCount(); }
234 KY_INLINE const Vec2f* TagVolume::GetPoints() const { return m_points.GetDataPtr(); }
235 KY_INLINE const Vec2f& TagVolume::GetPoint(KyUInt32 i) const { return m_points[i]; }
236 KY_INLINE const DynamicNavTag& TagVolume::GetNavTag() const { return m_navTag; }
237 KY_INLINE TagVolume::WorldStatus TagVolume::GetWorldStatus() const { return m_currentWorldStatus; }
238 KY_INLINE TagVolume::IntegrationStatus TagVolume::GetIntegrationStatus() const { return m_integrationStatus; }
239 KY_INLINE TagVolume::ObstacleType TagVolume::GetObstacleType() const { return m_obstacleType; }
240 KY_INLINE void* TagVolume::GetObstacleRawPtr() const { return m_obstacleRawPtr; }
241 KY_INLINE TagVolumeExtendOptions TagVolume::GetTagVolumeExtendOptions() const { return m_extendOptions; }
242 KY_INLINE const DatabaseBinding* TagVolume::GetDatabaseBinding() const { return GetTagVolumeDatabaseData().m_databaseBinding; }
243 KY_INLINE BoxObstacle* TagVolume::GetBoxObstacle() const
244 {
245  return ((m_obstacleType == ObstacleType_BoxObstacle) ? (BoxObstacle*)m_obstacleRawPtr : KY_NULL);
246 }
247 KY_INLINE CylinderObstacle* TagVolume::GetCylinderObstacle() const
248 {
249  return ((m_obstacleType == ObstacleType_CylinderObstacle) ? (CylinderObstacle*)m_obstacleRawPtr : KY_NULL);
250 }
251 
252 // WARNING Very internal. Used only internally during the generation process
253 KY_INLINE void TagVolume::SetWorld(World* world)
254 {
255  m_world = world;
256 }
257 
258 
259 } // namespace Kaim
260 
261 
262 #endif //Navigation_TagVolume_H
Class used to provide TagVolume initialization parameters.
Definition: tagvolume.h:36
void InitFromTagVolumeBlob(const TagVolumeBlob &blob)
neither the World nor the DatabaseBinding are set
Indicates that In each database, the altitude tolerance off the Database will be removed from Zmin...
Definition: tagvolume.h:32
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
DynamicNavTag m_navTag
This DynamicNavTag will be translated as NavTag in the DynamicNavMesh floors generated in the TagVolu...
Definition: tagvolume.h:91
KyFloat32 z
The size of the vector along the Z axis.
Definition: vec3f.h:229
void AddToWorld()
Adds the TagVolume to the World.
KyResult Init(const TagVolumeInitConfig &initConfig)
Initialize the TagVolume accordingly to the informations passed through the TagVolumeInitConfig.
void SetDefaults()
Sets all members to their default value.
Definition: tagvolume.h:50
Vec3f m_max
The maxima of the bounding box.
Definition: box3f.h:174
Indicates that In each database, the altitude tolerance off the Database will be added to Zmax...
Definition: tagvolume.h:30
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:118
#define KY_NULL
Null value.
Definition: types.h:247
TagVolumeExtendOptions
Definition: tagvolume.h:28
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
This class is a runtime container for Gameware Navigation WorldElements such as NavData, Bots, BoxObstacles, TagVolumes...
Definition: world.h:54
Ptr< DatabaseBinding > m_databaseBinding
Defines the Databases in which the TagVolume will be spatialized.
Definition: tagvolume.h:87
Indicates that In each database, the altitude tolerance off the Database will be removed from Zmin...
Definition: tagvolume.h:31
This class represents runtime-defined volumes with customized NavTag.
Definition: tagvolume.h:108
This class defines a two-dimensional vector whose coordinates are stored using floating-point numbers...
Definition: vec2f.h:24
DatabaseBinding is a collection of the databases to be used for world elements spatialization.
Definition: databasebinding.h:24
WorldElementType
Enumerates the WorldElement types.
Definition: worldelementtype.h:15
Base internal class used to represent elements that can be added to a World, such as instances of Dat...
Definition: worldelement.h:45
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
World * m_world
Mandatory: you must provide a World when calling TagVolume::Init().
Definition: tagvolume.h:82
Vec3f m_min
The minima of the bounding box.
Definition: box3f.h:173
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
This class represents a three-dimensional 6 freedom degrees unit transform.
Definition: transform.h:20
void RemoveFromWorld()
Removes the TagVolume from the World.
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