gwnavruntime/queries/blobs/nearestborderhalfedgefromposqueryblob.h Source File

nearestborderhalfedgefromposqueryblob.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 #pragma once
8 
14 
15 namespace Kaim
16 {
17 
18 class NearestBorderHalfEdgeFromPosQueryOutputBlob
19 {
20  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
21 public:
22  NearestBorderHalfEdgeFromPosQueryOutputBlob() : m_result(0) {}
23 
25 
26 public:
27  KyUInt32 m_result;
28  NavHalfEdgeBlob m_nearestHalfEdgeOnBorder;
29  NavHalfEdgeBlob m_nextHalfEdgeOnBorder;
30  NavHalfEdgeBlob m_prevHalfEdgeOnBorder;
31  Vec3f m_nearestPosOnHalfEdge;
32  KyFloat32 m_squareDistFromHalfEdge;
33 };
34 inline void SwapEndianness(Endianness::Target e, NearestBorderHalfEdgeFromPosQueryOutputBlob& self)
35 {
36  SwapEndianness(e, self.m_result);
37  SwapEndianness(e, self.m_nearestHalfEdgeOnBorder);
38  SwapEndianness(e, self.m_nextHalfEdgeOnBorder);
39  SwapEndianness(e, self.m_prevHalfEdgeOnBorder);
40  SwapEndianness(e, self.m_nearestPosOnHalfEdge);
41  SwapEndianness(e, self.m_squareDistFromHalfEdge);
42 }
43 
44 class NearestBorderHalfEdgeFromPosQueryOutputBlobBuilder : public BaseBlobBuilder<NearestBorderHalfEdgeFromPosQueryOutputBlob>
45 {
46 public:
47  NearestBorderHalfEdgeFromPosQueryOutputBlobBuilder(BaseNearestBorderHalfEdgeFromPosQuery* query) { m_query = query; }
48  virtual void DoBuild()
49  {
50  BLOB_SET(m_blob->m_result, (KyUInt32)m_query->GetResult());
51  BLOB_BUILD(m_blob->m_nearestHalfEdgeOnBorder, NavHalfEdgeBlobBuilder(m_query->GetNearestHalfEdgePtrOnBorder()));
52  BLOB_BUILD(m_blob->m_nextHalfEdgeOnBorder, NavHalfEdgeBlobBuilder(m_query->GetNextHalfEdgePtrAlongBorder()));
53  BLOB_BUILD(m_blob->m_prevHalfEdgeOnBorder, NavHalfEdgeBlobBuilder(m_query->GetPrevHalfEdgePtrAlongBorder()));
54  BLOB_SET(m_blob->m_nearestPosOnHalfEdge, m_query->GetNearestPosOnHalfEdge());
55  BLOB_SET(m_blob->m_squareDistFromHalfEdge, m_query->GetSquareDistFromNearestBorder());
56  }
57 
58 private:
59  BaseNearestBorderHalfEdgeFromPosQuery* m_query;
60 };
61 
62 class NearestBorderHalfEdgeFromPosQueryBlob
63 {
64  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
65  KY_ROOT_BLOB_CLASS(Query, NearestBorderHalfEdgeFromPosQueryBlob, 0)
66 public:
67  NearestBorderHalfEdgeFromPosQueryBlob() : m_queryInfoId(KyUInt32MAXVAL), m_databaseIdx(KyUInt32MAXVAL) {}
68 
69 public:
70  KyUInt32 m_queryInfoId;
71 
72  KyUInt32 m_databaseIdx;
73  Vec3f m_inputPos3f;
74  KyFloat32 m_horizontalTolerance;
75  PositionSpatializationRange m_positionSpatializationRange;
76 
77  BlobRef<NearestBorderHalfEdgeFromPosQueryOutputBlob> m_queryOutput;
78 };
79 inline void SwapEndianness(Endianness::Target e, NearestBorderHalfEdgeFromPosQueryBlob& self)
80 {
81  SwapEndianness(e, self.m_queryInfoId);
82  SwapEndianness(e, self.m_databaseIdx);
83  SwapEndianness(e, self.m_inputPos3f);
84  SwapEndianness(e, self.m_horizontalTolerance);
85  SwapEndianness(e, self.m_positionSpatializationRange);
86 
87  SwapEndianness(e, self.m_queryOutput);
88 }
89 
90 class NearestBorderHalfEdgeFromPosQueryBlobBuilder : public BaseBlobBuilder<NearestBorderHalfEdgeFromPosQueryBlob>
91 {
92 public:
93  NearestBorderHalfEdgeFromPosQueryBlobBuilder(BaseNearestBorderHalfEdgeFromPosQuery* query) { m_query = query; }
94  virtual void DoBuild()
95  {
96  BLOB_SET(m_blob->m_queryInfoId, m_query->m_queryInfoId);
97 
98  if (m_query->m_database != nullptr)
99  {
100  BLOB_SET(m_blob->m_databaseIdx, m_query->m_database->GetDatabaseIndex());
101  BLOB_SET(m_blob->m_inputPos3f, m_query->GetInputPos());
102  BLOB_SET(m_blob->m_horizontalTolerance, m_query->GetHorizontalTolerance());
103  BLOB_SET(m_blob->m_positionSpatializationRange, m_query->GetPositionSpatializationRange());
104 
105  switch (m_query->GetResult())
106  {
108  case NEARESTHALFEDGE_NOT_PROCESSED: break;
109  default: BUILD_REFERENCED_BLOB(m_blob->m_queryOutput, NearestBorderHalfEdgeFromPosQueryOutputBlobBuilder(m_query)); break;
110  }
111  }
112  }
113 
114 private:
115  BaseNearestBorderHalfEdgeFromPosQuery* m_query;
116 };
117 }
#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
#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
NearestBorderHalfEdgeFromPosQueryOutputBlob * 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
NearestBorderHalfEdgeFromPosQueryResult
Enumerates the possible results of a NearestBorderHalfEdgeFromPosQuery.
Definition: basenearestborderhalfedgefromposquery.h:20
Indicates the query has not yet been initialized.
Definition: basenearestborderhalfedgefromposquery.h:22
Indicates the query has not yet been launched.
Definition: basenearestborderhalfedgefromposquery.h:23
#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