gwnavruntime/queries/blobs/trianglefromposqueryblob.h Source File

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