gwnavgeneration/input/clientinputtagvolume.h Source File

clientinputtagvolume.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
8 
13 
14 namespace Kaim
15 {
16 
17 class ClientInputTagVolumeBlob;
18 class TagVolume;
19 class TagVolumeInitConfig;
20 
26 {
27  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
28 
29 public:
32 
43  KyResult Init(
44  const Vec3f* points, KyUInt32 pointsCount,
45  KyFloat32 altitudeMin, KyFloat32 altitudeMax,
46  const KyUInt32* blindDataBuffer = NULL, KyUInt32 blindDataCount = 0, Color color = DynamicNavTag::GetDefaultColor());
47 
48  KyResult InitInClientCoordinates(
49  const Vec3f* client_points, KyUInt32 pointsCount,
50  KyFloat32 client_altitudeMin, KyFloat32 client_altitudeMax,
51  const CoordSystem& coordSystem,
52  const KyUInt32* blindDataBuffer=NULL, KyUInt32 blindDataCount=0, Color color = DynamicNavTag::GetDefaultColor());
53 
54  KyResult Init(
55  const Vec3f* points, KyUInt32 pointsCount,
56  KyFloat32 altitudeMin, KyFloat32 altitudeMax,
57  const DynamicNavTag& navTag);
58 
59  KyResult InitInClientCoordinates(
60  const Vec3f* client_points, KyUInt32 pointsCount,
61  KyFloat32 client_altitudeMin, KyFloat32 client_altitudeMax,
62  const DynamicNavTag& navTag,
63  const CoordSystem& coordSystem);
64 
65  void InitFromBlob(const ClientInputTagVolumeBlob& tagVolumeBlob);
66 
67  KyUInt32 GetPointsCount() const { return m_polyline.GetCount(); }
68  KyFloat32 GetAltitudeMin() const { return m_altMin; }
69  KyFloat32 GetAltitudeMax() const { return m_altMax; }
70 
71  const Vec3f& GetPoint(KyUInt32 i) const;
72 
73  void CreateNavigationTagVolume(TagVolume& volume) const;
74  void CreateNavigationTagVolumeConfig(TagVolumeInitConfig& volumeConfig) const;
75 public:
77  DynamicNavTag m_navTag; //< Stores the NavTag set for this volume.
78  KyFloat32 m_altMin; //< The lower altitude limit of the volume.
79  KyFloat32 m_altMax; //< The upper altitude limit of the volume.
80 };
81 
82 
83 class ClientInputTagVolumeBlob
84 {
85  KY_CLASS_WITHOUT_COPY(ClientInputTagVolumeBlob)
86  KY_ROOT_BLOB_CLASS(Generator, ClientInputTagVolumeBlob, 0)
87 public:
88  ClientInputTagVolumeBlob() : m_index(0), m_navTagIdx(KyUInt32MAXVAL) {}
89 
90  bool operator==(const ClientInputTagVolumeBlob& other) const
91  {
92  if (m_polyline.GetCount() != other.m_polyline.GetCount())
93  {
94  return false;
95  }
96 
97  const Vec3f* thisPoints = m_polyline.GetValues();
98  const Vec3f* otherPoints = other.m_polyline.GetValues();
99  for (UPInt i = 0; i < m_polyline.GetCount(); ++i)
100  {
101  if (thisPoints[i] != otherPoints[i])
102  {
103  return false;
104  }
105  }
106  return m_navTag == other.m_navTag && m_altMax == other.m_altMax && m_altMin == other.m_altMin;
107  }
108  bool operator!=(const ClientInputTagVolumeBlob& other) const { return !operator==(other); }
109 
110 public:
111  BlobArray<Vec3f> m_polyline;
112  KyFloat32 m_altMin;
113  KyFloat32 m_altMax;
114  NavTag m_navTag;
115  KyUInt32 m_index;
116  mutable KyUInt32 m_navTagIdx;
117 };
118 inline void SwapEndianness(Endianness::Target e, ClientInputTagVolumeBlob& self)
119 {
120  SwapEndianness(e, self.m_polyline);
121  SwapEndianness(e, self.m_altMin);
122  SwapEndianness(e, self.m_altMax);
123  SwapEndianness(e, self.m_navTag);
124  SwapEndianness(e, self.m_index);
125  SwapEndianness(e, self.m_navTagIdx);
126 }
127 
128 class ClientInputTagVolumeBlobBuilder : public BaseBlobBuilder<ClientInputTagVolumeBlob>
129 {
130 public:
131  ClientInputTagVolumeBlobBuilder(const ClientInputTagVolume& tagVolume) : m_tagVolume(&tagVolume) {}
132 private:
133  void DoBuild()
134  {
135  if (IsWriteMode())
136  {
137  m_blob->m_index = 0;
138  m_blob->m_altMin = m_tagVolume->m_altMin;
139  m_blob->m_altMax = m_tagVolume->m_altMax;
140  }
141 
142  BLOB_ARRAY_COPY_2(m_blob->m_polyline, m_tagVolume->m_polyline);
143  BLOB_BUILD(m_blob->m_navTag, NavTagBlobBuilder(m_tagVolume->m_navTag));
144  }
145 private:
146  const ClientInputTagVolume* m_tagVolume;
147 };
148 
149 }
150 
151 
152 
TagVolumeInitConfig provides TagVolume initialization parameters.
Definition: tagvolume.h:34
void CreateNavigationTagVolume(TagVolume &volume) const
Build a Runtime Tag Volume.
Definition: clientinputtagvolume.cpp:83
KyResult Init(const Vec3f *points, KyUInt32 pointsCount, KyFloat32 altitudeMin, KyFloat32 altitudeMax, const KyUInt32 *blindDataBuffer=NULL, KyUInt32 blindDataCount=0, Color color=DynamicNavTag::GetDefaultColor())
Sets up an instance of this class with any required components and configuration parameters.
Definition: clientinputtagvolume.cpp:12
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
Kaim::KyArray< Vec3f > m_polyline
Stores the polyline set for this volume. Do not modify directly. Access using GetPoint() ...
Definition: clientinputtagvolume.h:76
KyFloat32 GetAltitudeMin() const
Retrieves the max altitude of the extruded polyline.
Definition: clientinputtagvolume.h:68
#define BLOB_BUILD(blob, builder)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:175
This class maintains the mapping between the system of coordinate axes used by the client game engine...
Definition: coordsystem.h:119
The Generator is the principal class in the NavData generation system.
Definition: generator.h:56
KyUInt32 GetPointsCount() const
Retrieves the number of unique points in the polyline that outlines this volume.
Definition: clientinputtagvolume.h:67
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:162
const Vec3f & GetPoint(KyUInt32 i) const
Retrieves the point at the specified index within the polyline that outlines this volume...
Definition: clientinputtagvolume.cpp:66
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
ClientInputTagVolume()
Creates an unitialized ClientInputTagVolume, that must be set up through a call to Init()...
Definition: clientinputtagvolume.h:31
This class represents runtime-defined volumes with customized NavTag.
Definition: tagvolume.h:119
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
Navigation return code class.
Definition: types.h:108
ClientInputTagVolumeBlob * m_blob
The blob maintained by this builder. Only modify using the macros listed under DoBuild().
Definition: baseblobbuilder.h:113
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
bool IsWriteMode()
Indicates whether the builder is operating in COUNT mode or in WRITE mode.
Definition: baseblobbuilder.h:43
RGBA color.
Definition: color.h:16
#define BLOB_ARRAY_COPY_2(blobArray, ky_array)
same as BLOB_ARRAY_COPY but uses Kaim::Array as input
Definition: baseblobbuilder.h:155
KyFloat32 GetAltitudeMax() const
Retrieves the min altitude of the extruded polyline.
Definition: clientinputtagvolume.h:69
Represents a volume using a two-dimensional polyline extruded vertically along the "up" axis associat...
Definition: clientinputtagvolume.h:25
#define KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16