gwnavruntime/queries/blobs/bestgraphvertexpathfinderqueryblob.h Source File

bestgraphvertexpathfinderqueryblob.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_BestGraphVertexPathFinderQueryBlob_H
9 #define Navigation_BestGraphVertexPathFinderQueryBlob_H
10 
17 
18 
19 namespace Kaim
20 {
21 
22 class BestGraphVertexPathFinderQueryOutputBlob
23 {
24  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
25 
26 public:
27  BestGraphVertexPathFinderQueryOutputBlob() : m_result(0) {}
28 
30 
31 public:
32  KyUInt32 m_result;
33  TimeSlicedQueryInfoBlob m_timeSlicedQueryInfo;
34  NavTriangleBlob m_startTriangle;
35  PathBlob m_pathBlob;
36 };
37 inline void SwapEndianness(Endianness::Target e, BestGraphVertexPathFinderQueryOutputBlob& self)
38 {
39  SwapEndianness(e, self.m_result );
40  SwapEndianness(e, self.m_timeSlicedQueryInfo);
41  SwapEndianness(e, self.m_startTriangle );
42  SwapEndianness(e, self.m_pathBlob );
43 }
44 
45 
46 class BestGraphVertexPathFinderQueryOutputBlobBuilder : public BaseBlobBuilder<BestGraphVertexPathFinderQueryOutputBlob>
47 {
48 public:
49  BestGraphVertexPathFinderQueryOutputBlobBuilder(BaseBestGraphVertexPathFinderQuery* query)
50  : m_query(query)
51  {}
52 
53  virtual void DoBuild()
54  {
55  BLOB_SET(m_blob->m_result, (KyUInt32)m_query->GetResult());
56  BLOB_BUILD(m_blob->m_timeSlicedQueryInfo, TimeSlicedQueryBlobBuilder(m_query));
57  BLOB_BUILD(m_blob->m_startTriangle, NavTriangleBlobBuilder(m_query->GetStartTrianglePtr()));
58 
59  if (m_query->GetResult() == BESTGRAPHVERTEX_DONE_PATH_FOUND)
60  BLOB_BUILD(m_blob->m_pathBlob, PathBlobBuilder(m_query->GetPath()));
61  }
62 
63 private:
64  BaseBestGraphVertexPathFinderQuery* m_query;
65 };
66 
67 class BestGraphVertexPathFinderQueryBlob
68 {
69  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
70  KY_ROOT_BLOB_CLASS(Query, BestGraphVertexPathFinderQueryBlob, 0)
71 
72 public:
73  BestGraphVertexPathFinderQueryBlob() : m_queryInfoId(KyUInt32MAXVAL), m_databaseIdx(KyUInt32MAXVAL) {}
74 
75 public:
76  KyUInt32 m_queryInfoId;
77 
78  KyUInt32 m_databaseIdx;
79  KyFloat32 m_fromOutsideNavMeshDistance;
80  KyFloat32 m_propagationRadius;
81  KyUInt8 m_enableAdvancedVisualDebug;
82 
83  Vec3f m_startPos3f;
84  PositionSpatializationRange m_positionSpatializationRange;
85  BlobRef<BestGraphVertexPathFinderQueryOutputBlob> m_queryOutput;
86 };
87 
88 inline void SwapEndianness(Endianness::Target e, BestGraphVertexPathFinderQueryBlob& self)
89 {
90  SwapEndianness(e, self.m_queryInfoId );
91  SwapEndianness(e, self.m_databaseIdx );
92  SwapEndianness(e, self.m_fromOutsideNavMeshDistance );
93  SwapEndianness(e, self.m_propagationRadius );
94  SwapEndianness(e, self.m_enableAdvancedVisualDebug );
95  SwapEndianness(e, self.m_startPos3f );
96  SwapEndianness(e, self.m_positionSpatializationRange );
97  SwapEndianness(e, self.m_queryOutput );
98 }
99 
100 class BestGraphVertexPathFinderQueryBlobBuilder: public BaseBlobBuilder<BestGraphVertexPathFinderQueryBlob>
101 {
102 public:
103  BestGraphVertexPathFinderQueryBlobBuilder(BaseBestGraphVertexPathFinderQuery* query)
104  : m_query(query)
105  {}
106 
107  virtual void DoBuild()
108  {
109  BLOB_SET(m_blob->m_queryInfoId, m_query->m_queryInfoId);
110 
111  if (m_query->m_database != KY_NULL)
112  {
113  BLOB_SET(m_blob->m_databaseIdx , m_query->m_database->GetDatabaseIndex());
114  BLOB_SET(m_blob->m_startPos3f , m_query->GetStartPos());
115  BLOB_SET(m_blob->m_positionSpatializationRange , m_query->GetPositionSpatializationRange());
116  BLOB_SET(m_blob->m_fromOutsideNavMeshDistance , m_query->GetFromOutsideNavMeshDistance());
117  BLOB_SET(m_blob->m_propagationRadius , m_query->GetPropagationRadius());
118  BLOB_SET(m_blob->m_enableAdvancedVisualDebug , m_query->m_enableAdvancedVisualDebug ? 1 : 0);
119 
120  switch (m_query->GetResult())
121  {
124  break;
125  default:
126  BUILD_REFERENCED_BLOB(m_blob->m_queryOutput, BestGraphVertexPathFinderQueryOutputBlobBuilder(m_query));
127  break;
128  }
129  }
130  }
131 
132 private:
133  BaseBestGraphVertexPathFinderQuery* m_query;
134 };
135 }
136 
137 #endif // Kaim_AstarQueryInputBlob_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
Indicates the query has not yet been initialized.
Definition: basebestgraphvertexpathfinderquery.h:24
#define KY_NULL
Null value.
Definition: types.h:247
Indicates the query has not yet been launched.
Definition: basebestgraphvertexpathfinderquery.h:25
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
unsigned char KyUInt8
Type used internally to represent an unsigned 8-bit integer.
Definition: types.h:41
BestGraphVertexPathFinderQueryOutputBlob * 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
Indicates that a path has been found between the start and destination.
Definition: basebestgraphvertexpathfinderquery.h:47
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
BestGraphVertexPathFinderQueryResult
Enumerates the possible results of an BestGraphVertexPathFinderQuery.
Definition: basebestgraphvertexpathfinderquery.h:22
#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