gwnavruntime/queries/blobs/insideposfromoutsideposqueryblob.h Source File

insideposfromoutsideposqueryblob.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_InsidePosFromOutsidePosQueryBlob_H
9 #define Navigation_InsidePosFromOutsidePosQueryBlob_H
10 
15 
16 namespace Kaim
17 {
18 
19 class InsidePosFromOutsidePosQueryOutputBlob
20 {
21  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
22 public:
23  InsidePosFromOutsidePosQueryOutputBlob() : m_result(0) {}
24 
25  InsidePosFromOutsidePosQueryResult GetResult() const { return (InsidePosFromOutsidePosQueryResult)m_result; }
26 public:
27  KyUInt32 m_result;
28  Vec3f m_insidePos3f;
29  NavTriangleBlob m_insidePosTriangle;
30 };
31 inline void SwapEndianness(Endianness::Target e, InsidePosFromOutsidePosQueryOutputBlob& self)
32 {
33  SwapEndianness(e, self.m_result);
34  SwapEndianness(e, self.m_insidePos3f);
35  SwapEndianness(e, self.m_insidePosTriangle);
36 }
37 
38 
39 class InsidePosFromOutsidePosQueryOutputBlobBuilder : public BaseBlobBuilder<InsidePosFromOutsidePosQueryOutputBlob>
40 {
41 public:
42  InsidePosFromOutsidePosQueryOutputBlobBuilder(BaseInsidePosFromOutsidePosQuery* 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_insidePos3f, m_query->GetInsidePos());
47  BLOB_BUILD(m_blob->m_insidePosTriangle, NavTriangleBlobBuilder(m_query->GetInsidePosTrianglePtr()));
48  }
49 
50 private:
51  BaseInsidePosFromOutsidePosQuery* m_query;
52 };
53 
54 
55 class InsidePosFromOutsidePosQueryBlob
56 {
57  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
58  KY_ROOT_BLOB_CLASS(Query, InsidePosFromOutsidePosQueryBlob, 0)
59 public:
60  InsidePosFromOutsidePosQueryBlob() : m_queryInfoId(KyUInt32MAXVAL), m_databaseIdx(KyUInt32MAXVAL) {}
61 
62 public:
63  KyUInt32 m_queryInfoId;
64 
65  KyUInt32 m_databaseIdx;
66  Vec3f m_inputPos3f;
67  Vec2f m_castDirection; // set to Vec2f(KyFloat32MAXVAL, KyFloat32MAXVAL) is queryMode is INSIDEPOSFROMOUTSIDE_FROM_NEAREST_HALFEDGE
68  KyFloat32 m_distFromObstacle;
69  KyFloat32 m_horizontalTolerance;
70  PositionSpatializationRange m_positionSpatializationRange;
71 
72  BlobRef<InsidePosFromOutsidePosQueryOutputBlob> m_queryOutput;
73 };
74 inline void SwapEndianness(Endianness::Target e, InsidePosFromOutsidePosQueryBlob& 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_castDirection );
80  SwapEndianness(e, self.m_distFromObstacle );
81  SwapEndianness(e, self.m_horizontalTolerance);
82  SwapEndianness(e, self.m_positionSpatializationRange);
83 
84  SwapEndianness(e, self.m_queryOutput);
85 }
86 
87 class InsidePosFromOutsidePosQueryBlobBuilder : public BaseBlobBuilder<InsidePosFromOutsidePosQueryBlob>
88 {
89 public:
90  InsidePosFromOutsidePosQueryBlobBuilder(BaseInsidePosFromOutsidePosQuery* query) { m_query = query; }
91  virtual void DoBuild()
92  {
93  BLOB_SET(m_blob->m_queryInfoId, m_query->m_queryInfoId);
94 
95  if (m_query->m_database != KY_NULL)
96  {
97  BLOB_SET(m_blob->m_databaseIdx , m_query->m_database->GetDatabaseIndex());
98  BLOB_SET(m_blob->m_inputPos3f , m_query->GetInputPos());
99  BLOB_SET(m_blob->m_castDirection , m_query->GetCastDirection());
100  BLOB_SET(m_blob->m_distFromObstacle , m_query->GetDistFromObstacle());
101  BLOB_SET(m_blob->m_horizontalTolerance , m_query->GetHorizontalTolerance());
102  BLOB_SET(m_blob->m_positionSpatializationRange, m_query->GetPositionSpatializationRange());
103 
104  switch (m_query->GetResult())
105  {
108  break;
109  default:
110  BUILD_REFERENCED_BLOB(m_blob->m_queryOutput, InsidePosFromOutsidePosQueryOutputBlobBuilder(m_query));
111  break;
112  }
113  }
114  }
115 
116 private:
117  BaseInsidePosFromOutsidePosQuery* m_query;
118 };
119 }
120 
121 #endif // Kaim_InsidePosFromOutsidePosQueryInputBlob_H
InsidePosFromOutsidePosQueryResult
Enumerates the possible results of an InsidePosFromOutsidePosQuery.
Definition: baseinsideposfromoutsideposquery.h:26
#define BLOB_SET(blob, value)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:136
Indicates the query has not yet been initialized.
Definition: baseinsideposfromoutsideposquery.h:28
#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
InsidePosFromOutsidePosQueryOutputBlob * 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 the query has not yet been launched.
Definition: baseinsideposfromoutsideposquery.h:29
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#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