gwnavruntime/queries/blobs/trianglefromposqueryblob.h Source File

trianglefromposqueryblob.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_TriangleFromPosQueryBlob_H
9 #define Navigation_TriangleFromPosQueryBlob_H
10 
15 
16 namespace Kaim
17 {
18 
19 class TriangleFromPosQueryOutputBlob
20 {
21  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
22 public:
23  TriangleFromPosQueryOutputBlob() : m_result(0) {}
24 
25  TriangleFromPosQueryResult GetResult() const { return (TriangleFromPosQueryResult)m_result; }
26 public:
27  KyUInt32 m_result;
28  NavTriangleBlob m_resultTrianglePtr;
29  KyFloat32 m_altitudeOfProjection;
30 };
31 inline void SwapEndianness(Endianness::Target e, TriangleFromPosQueryOutputBlob& self)
32 {
33  SwapEndianness(e, self.m_result);
34  SwapEndianness(e, self.m_resultTrianglePtr);
35  SwapEndianness(e, self.m_altitudeOfProjection );
36 }
37 
38 
39 class TriangleFromPosQueryOutputBlobBuilder : public BaseBlobBuilder<TriangleFromPosQueryOutputBlob>
40 {
41 public:
42  TriangleFromPosQueryOutputBlobBuilder(TriangleFromPosQuery* query) { m_query = query; }
43  virtual void DoBuild()
44  {
45  BLOB_SET(m_blob->m_result, (KyUInt32)m_query->GetResult());
46  BLOB_SET(m_blob->m_altitudeOfProjection, m_query->GetAltitudeOfProjectionInTriangle());
47  BLOB_BUILD(m_blob->m_resultTrianglePtr, NavTriangleBlobBuilder(m_query->GetResultTrianglePtr()));
48  }
49 
50 private:
51  TriangleFromPosQuery* m_query;
52 };
53 
54 
55 class TriangleFromPosQueryBlob
56 {
57  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
58  KY_ROOT_BLOB_CLASS(Query, TriangleFromPosQueryBlob, 0)
59 public:
60  TriangleFromPosQueryBlob() : m_queryInfoId(KyUInt32MAXVAL), m_databaseIdx(KyUInt32MAXVAL) {}
61 
62  TriangleFromPosQueryType GetQueryType() const { return (TriangleFromPosQueryType)m_queryType; }
63 
64 public:
65  KyUInt32 m_queryInfoId;
66 
67  KyUInt32 m_databaseIdx;
68  Vec3f m_inputPos3f;
69  KyUInt32 m_queryType;
70  PositionSpatializationRange m_positionSpatializationRange;
71 
72  BlobRef<TriangleFromPosQueryOutputBlob> m_queryOutput;
73 };
74 inline void SwapEndianness(Endianness::Target e, TriangleFromPosQueryBlob& self)
75 {
76  SwapEndianness(e, self.m_queryInfoId);
77  SwapEndianness(e, self.m_databaseIdx);
78  SwapEndianness(e, self.m_inputPos3f);
79  SwapEndianness(e, self.m_queryType);
80  SwapEndianness(e, self.m_positionSpatializationRange);
81 
82  SwapEndianness(e, self.m_queryOutput);
83 }
84 
85 class TriangleFromPosQueryBlobBuilder : public BaseBlobBuilder<TriangleFromPosQueryBlob>
86 {
87 public:
88  TriangleFromPosQueryBlobBuilder(TriangleFromPosQuery* query) { m_query = query; }
89  virtual void DoBuild()
90  {
91  BLOB_SET(m_blob->m_queryInfoId, m_query->m_queryInfoId);
92 
93  if (m_query->m_database != KY_NULL)
94  {
95  BLOB_SET(m_blob->m_databaseIdx , m_query->m_database->GetDatabaseIndex());
96  BLOB_SET(m_blob->m_inputPos3f , m_query->GetInputPos());
97  BLOB_SET(m_blob->m_queryType , (KyUInt32)m_query->GetQueryType());
98  BLOB_SET(m_blob->m_positionSpatializationRange, m_query->GetPositionSpatializationRange());
99 
100  switch (m_query->GetResult())
101  {
104  break;
105  default:
106  BUILD_REFERENCED_BLOB(m_blob->m_queryOutput, TriangleFromPosQueryOutputBlobBuilder(m_query));
107  break;
108  }
109  }
110  }
111 
112 private:
113  TriangleFromPosQuery* m_query;
114 };
115 }
116 
117 #endif // Kaim_TriangleFromPosQueryInputBlob_H
Indicates the query has not yet been initialized.
Definition: trianglefromposquery.h:31
#define BLOB_SET(blob, value)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:136
TriangleFromPosQueryResult
Enumerates the possible results of a TriangleFromPosQuery.
Definition: trianglefromposquery.h:29
#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
TriangleFromPosQueryOutputBlob * 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
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
TriangleFromPosQueryType
Enumerates the possible ways a TriangleFromPosQuery can choose the triangle it retrieves.
Definition: trianglefromposquery.h:41
#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
Indicates the query has not yet been launched.
Definition: trianglefromposquery.h:32
#define BUILD_REFERENCED_BLOB(blobRef, builder)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:197