gwnavruntime/queries/blobs/nearestborderhalfedgefromposqueryblob.h Source File

nearestborderhalfedgefromposqueryblob.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 #ifndef Navigation_NearestObstacleHalfEdgeFromPosQueryBlob_H
9 #define Navigation_NearestObstacleHalfEdgeFromPosQueryBlob_H
10 
16 
17 namespace Kaim
18 {
19 
20 class NearestBorderHalfEdgeFromPosQueryOutputBlob
21 {
22  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
23 public:
24  NearestBorderHalfEdgeFromPosQueryOutputBlob() : m_result(0) {}
25 
27 public:
28  KyUInt32 m_result;
29  NavHalfEdgeBlob m_nearestHalfEdgeOnBorder;
30  NavHalfEdgeBlob m_nextHalfEdgeOnBorder;
31  NavHalfEdgeBlob m_prevHalfEdgeOnBorder;
32  Vec3f m_nearestPosOnHalfEdge;
33  KyFloat32 m_squareDistFromHalfEdge;
34 };
35 inline void SwapEndianness(Endianness::Target e, NearestBorderHalfEdgeFromPosQueryOutputBlob& self)
36 {
37  SwapEndianness(e, self.m_result);
38  SwapEndianness(e, self.m_nearestHalfEdgeOnBorder);
39  SwapEndianness(e, self.m_nextHalfEdgeOnBorder );
40  SwapEndianness(e, self.m_prevHalfEdgeOnBorder );
41  SwapEndianness(e, self.m_nearestPosOnHalfEdge );
42  SwapEndianness(e, self.m_squareDistFromHalfEdge );
43 }
44 
45 
46 class NearestBorderHalfEdgeFromPosQueryOutputBlobBuilder : public BaseBlobBuilder<NearestBorderHalfEdgeFromPosQueryOutputBlob>
47 {
48 public:
49  NearestBorderHalfEdgeFromPosQueryOutputBlobBuilder(BaseNearestBorderHalfEdgeFromPosQuery* query) { m_query = query; }
50  virtual void DoBuild()
51  {
52  BLOB_SET(m_blob->m_result, (KyUInt32)m_query->GetResult());
53  BLOB_BUILD(m_blob->m_nearestHalfEdgeOnBorder, NavHalfEdgeBlobBuilder(m_query->GetNearestHalfEdgePtrOnBorder()));
54  BLOB_BUILD(m_blob->m_nextHalfEdgeOnBorder , NavHalfEdgeBlobBuilder(m_query->GetNextHalfEdgePtrAlongBorder()));
55  BLOB_BUILD(m_blob->m_prevHalfEdgeOnBorder , NavHalfEdgeBlobBuilder(m_query->GetPrevHalfEdgePtrAlongBorder()));
56  BLOB_SET(m_blob->m_nearestPosOnHalfEdge, m_query->GetNearestPosOnHalfEdge());
57  BLOB_SET(m_blob->m_squareDistFromHalfEdge, m_query->GetSquareDistFromNearestBorder());
58  }
59 
60 private:
61  BaseNearestBorderHalfEdgeFromPosQuery* m_query;
62 };
63 
64 
65 class NearestBorderHalfEdgeFromPosQueryBlob
66 {
67  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
68  KY_ROOT_BLOB_CLASS(Query, NearestBorderHalfEdgeFromPosQueryBlob, 0)
69 public:
70  NearestBorderHalfEdgeFromPosQueryBlob() : m_queryInfoId(KyUInt32MAXVAL), m_databaseIdx(KyUInt32MAXVAL) {}
71 
72 public:
73  KyUInt32 m_queryInfoId;
74 
75  KyUInt32 m_databaseIdx;
76  Vec3f m_inputPos3f;
77  KyFloat32 m_horizontalTolerance;
78  PositionSpatializationRange m_positionSpatializationRange;
79 
80  BlobRef<NearestBorderHalfEdgeFromPosQueryOutputBlob> m_queryOutput;
81 };
82 inline void SwapEndianness(Endianness::Target e, NearestBorderHalfEdgeFromPosQueryBlob& self)
83 {
84  SwapEndianness(e, self.m_queryInfoId);
85  SwapEndianness(e, self.m_databaseIdx);
86  SwapEndianness(e, self.m_inputPos3f);
87  SwapEndianness(e, self.m_horizontalTolerance);
88  SwapEndianness(e, self.m_positionSpatializationRange);
89 
90  SwapEndianness(e, self.m_queryOutput);
91 }
92 
93 class NearestBorderHalfEdgeFromPosQueryBlobBuilder : public BaseBlobBuilder<NearestBorderHalfEdgeFromPosQueryBlob>
94 {
95 public:
96  NearestBorderHalfEdgeFromPosQueryBlobBuilder(BaseNearestBorderHalfEdgeFromPosQuery* query) { m_query = query; }
97  virtual void DoBuild()
98  {
99  BLOB_SET(m_blob->m_queryInfoId, m_query->m_queryInfoId);
100 
101  if (m_query->m_database != KY_NULL)
102  {
103  BLOB_SET(m_blob->m_databaseIdx , m_query->m_database->GetDatabaseIndex());
104  BLOB_SET(m_blob->m_inputPos3f , m_query->GetInputPos());
105  BLOB_SET(m_blob->m_horizontalTolerance , m_query->GetHorizontalTolerance());
106  BLOB_SET(m_blob->m_positionSpatializationRange, m_query->GetPositionSpatializationRange());
107 
108  switch (m_query->GetResult())
109  {
112  break;
113  default:
114  BUILD_REFERENCED_BLOB(m_blob->m_queryOutput, NearestBorderHalfEdgeFromPosQueryOutputBlobBuilder(m_query));
115  break;
116  }
117  }
118  }
119 
120 private:
121  BaseNearestBorderHalfEdgeFromPosQuery* m_query;
122 };
123 }
124 
125 #endif // Kaim_NearestObstacleHalfEdgeFromPosQueryInputBlob_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
#define KY_NULL
Null value.
Definition: types.h:247
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
NearestBorderHalfEdgeFromPosQueryOutputBlob * m_blob
The blob maintained by this builder. Only modify using the macros listed under DoBuild().
Definition: baseblobbuilder.h:117
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
NearestBorderHalfEdgeFromPosQueryResult
Enumerates the possible results of a NearestBorderHalfEdgeFromPosQuery.
Definition: basenearestborderhalfedgefromposquery.h:29
Indicates the query has not yet been initialized.
Definition: basenearestborderhalfedgefromposquery.h:31
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Indicates the query has not yet been launched.
Definition: basenearestborderhalfedgefromposquery.h:32
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
#define BUILD_REFERENCED_BLOB(blobRef, builder)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:197