gwnavruntime/world/tagvolumeblob.h Source File

tagvolumeblob.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: LAPA - secondary contact: NOBODY
9 #ifndef Navigation_TagVolumeBlob_H
10 #define Navigation_TagVolumeBlob_H
11 
14 
15 
16 namespace Kaim
17 {
18 
19 class TagVolumeBlob
20 {
21  KY_CLASS_WITHOUT_COPY(TagVolumeBlob)
22  KY_ROOT_BLOB_CLASS(NavData, TagVolumeBlob, 106)
23 
24 public:
25  TagVolumeBlob() : m_navTagIdx(KyUInt32MAXVAL) {}
26 
27  bool operator==(const TagVolumeBlob& other) const
28  {
29  if ((m_points.GetCount() != other.m_points.GetCount()) ||
30  (m_aabb != other.m_aabb) ||
31  (m_obstacleType != other.m_obstacleType) ||
32  (m_navTag != other.m_navTag))
33  {
34  return false;
35  }
36 
37  const Vec2f* thisPoints = m_points.GetValues();
38  const Vec2f* otherPoints = other.m_points.GetValues();
39  for (KyUInt32 i = 0; i < m_points.GetCount(); ++i)
40  {
41  if (thisPoints[i] != otherPoints[i])
42  return false;
43  }
44 
45  return true;
46  }
47  bool operator!=(const TagVolumeBlob& other) const { return !operator==(other); }
48 
49  TagVolume::ObstacleType GetObstacleType() const { return (TagVolume::ObstacleType)m_obstacleType; }
50  TagVolumeExtendOptions GetTagVolumeExtendOptions() const { return (TagVolumeExtendOptions)m_tagVolumeExtendOptions; }
51 public:
52  KyUInt32 m_visualDebugId;
53  BlobArray<Vec2f> m_points;
54  Box3f m_aabb;
55  KyUInt16 m_obstacleType; // cast this into TagVolume::ObstacleType
56  KyUInt16 m_tagVolumeExtendOptions; //TagVolumeExtendOptions
57  NavTag m_navTag;
58  mutable KyUInt32 m_navTagIdx;
59  DatabaseBindingBlob m_databaseBindings;
60 };
61 
62 inline void SwapEndianness(Endianness::Target e, TagVolumeBlob& self)
63 {
64  SwapEndianness(e, self.m_visualDebugId);
65  SwapEndianness(e, self.m_points);
66  SwapEndianness(e, self.m_aabb);
67  SwapEndianness(e, self.m_obstacleType);
68  SwapEndianness(e, self.m_tagVolumeExtendOptions);
69  SwapEndianness(e, self.m_navTag);
70  SwapEndianness(e, self.m_navTagIdx);
71  SwapEndianness(e, self.m_databaseBindings);
72 }
73 
74 class TagVolumeBlobBuilder : public BaseBlobBuilder<TagVolumeBlob>
75 {
76 public:
77  TagVolumeBlobBuilder(const TagVolume* tagVolume) : m_tagVolume(tagVolume) {}
78 
79 private:
80  void DoBuild()
81  {
82  if (m_tagVolume)
83  {
84  BLOB_SET(m_blob->m_visualDebugId, m_tagVolume->GetVisualDebugId());
85  BLOB_SET(m_blob->m_aabb, m_tagVolume->GetAABB());
86  BLOB_SET(m_blob->m_obstacleType, (KyUInt16)m_tagVolume->GetObstacleType());
87  BLOB_SET(m_blob->m_tagVolumeExtendOptions, (KyUInt16)m_tagVolume->GetTagVolumeExtendOptions());
88  BLOB_ARRAY_COPY(m_blob->m_points, m_tagVolume->GetPoints(), m_tagVolume->GetPointCount());
89  BLOB_BUILD(m_blob->m_navTag, NavTagBlobBuilder(m_tagVolume->GetNavTag()));
90  BLOB_BUILD(m_blob->m_databaseBindings, DatabaseBindingBlobBuilder(m_tagVolume->GetDatabaseBinding()));
91  }
92  }
93 
94  const TagVolume* m_tagVolume;
95 };
96 
97 class TagVolumeContextBlob
98 {
99  KY_CLASS_WITHOUT_COPY(TagVolumeContextBlob)
100  KY_ROOT_BLOB_CLASS(NavData, TagVolumeContextBlob, 0)
101 
102 public:
103  TagVolumeContextBlob() {}
104 
105  TagVolume::IntegrationStatus GetIntegrationStatus() const { return (TagVolume::IntegrationStatus)m_integrationStatus; }
106  TagVolume::WorldStatus GetWorldStatus() const { return (TagVolume::WorldStatus)m_worldStatus; }
107 public:
108  KyUInt32 m_visualDebugId;
109  KyUInt16 m_integrationStatus; // cast this into IntegratonStatus
110  KyUInt16 m_worldStatus; // cast this into WorldStatus;
111 };
112 
113 inline void SwapEndianness(Endianness::Target e, TagVolumeContextBlob& self)
114 {
115  SwapEndianness(e, self.m_visualDebugId);
116  SwapEndianness(e, self.m_integrationStatus);
117  SwapEndianness(e, self.m_worldStatus);
118 }
119 
120 class TagVolumeContextBlobBuilder : public BaseBlobBuilder<TagVolumeContextBlob>
121 {
122 public:
123  TagVolumeContextBlobBuilder(const TagVolume* tagVolume) : m_tagVolume(tagVolume) {}
124 
125 private:
126  void DoBuild()
127  {
128  if (m_tagVolume)
129  {
130  BLOB_SET(m_blob->m_visualDebugId, m_tagVolume->GetVisualDebugId());
131  BLOB_SET(m_blob->m_integrationStatus, (KyUInt16)m_tagVolume->GetIntegrationStatus());
132  BLOB_SET(m_blob->m_worldStatus, (KyUInt16)m_tagVolume->GetWorldStatus());
133  }
134  }
135 
136  const TagVolume* m_tagVolume;
137 };
138 
139 } // namespace Kaim
140 
141 #endif // Navigation_TagVolumeBlob_H
#define BLOB_SET(blob, value)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:136
#define BLOB_BUILD(blob, builder)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:189
TagVolumeExtendOptions
Definition: tagvolume.h:28
#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
TagVolumeBlob * m_blob
The blob maintained by this builder. Only modify using the macros listed under DoBuild().
Definition: baseblobbuilder.h:117
Definition: gamekitcrowddispersion.h:20
unsigned short KyUInt16
Type used internally to represent an unsigned 16-bit integer.
Definition: types.h:40
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#define BLOB_ARRAY_COPY(blobArray, src, count)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:161
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226