gwnavruntime/queries/blobs/bestgraphvertexpathfinderqueryblob.h Source File

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