gwnavruntime/queries/blobs/pathfinderqueryblob.h Source File

pathfinderqueryblob.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 
12 namespace Kaim
13 {
14 
15 class PathFinderQueryBlob
16 {
17  KY_ROOT_BLOB_CLASS(Query, PathFinderQueryBlob, 0)
18 
19 public:
20  PathFinderQueryBlob() : m_queryType(KyUInt32MAXVAL), m_result((KyUInt32)IPathFinderQuery::PathFinderNotInitialized), m_isPathfinderWithDest(0) {}
21 
22  Vec3f m_startPos3f;
23  Vec3f m_destPos3f;
24  KyUInt32 m_queryType;
25  KyUInt32 m_result;
26  BlobArray<char> m_errorMessage;
27  KyUInt8 m_isPathfinderWithDest; // 0(false) or 1(true)
28 };
29 inline void SwapEndianness(Endianness::Target e, PathFinderQueryBlob& self)
30 {
31  SwapEndianness(e, self.m_startPos3f);
32  SwapEndianness(e, self.m_destPos3f);
33  SwapEndianness(e, self.m_queryType);
34  SwapEndianness(e, self.m_result);
35  SwapEndianness(e, self.m_errorMessage);
36  SwapEndianness(e, self.m_isPathfinderWithDest);
37 }
38 
39 class PathFinderInfoBlobBuilder: public BaseBlobBuilder<PathFinderQueryBlob>
40 {
41  KY_CLASS_WITHOUT_COPY(PathFinderInfoBlobBuilder)
42 
43 public:
44  PathFinderInfoBlobBuilder(const IPathFinderQuery* pathFinderQuery): m_pathFinderQuery(pathFinderQuery) {}
45  ~PathFinderInfoBlobBuilder() {}
46 
47 private:
48  virtual void DoBuild()
49  {
50  if (m_pathFinderQuery != NULL)
51  {
52  BLOB_SET(m_blob->m_startPos3f, m_pathFinderQuery->m_startPos3f);
53  const Vec3f* dest = m_pathFinderQuery->GetDestination();
54  if (dest == nullptr)
55  {
56  BLOB_SET(m_blob->m_isPathfinderWithDest, 1);
58  }
59  else
60  {
61  BLOB_SET(m_blob->m_isPathfinderWithDest, 1);
62  BLOB_SET(m_blob->m_destPos3f, *dest);
63  }
64 
65  BLOB_SET(m_blob->m_queryType, (KyUInt32)m_pathFinderQuery->GetType());
66  BLOB_SET(m_blob->m_result, (KyUInt32)m_pathFinderQuery->GetPathFinderResult());
67  String text;
68  m_pathFinderQuery->GetPathFinderTextResult(text);
69  BLOB_STRING(m_blob->m_errorMessage, text.ToCStr());
70  }
71  }
72 
73 private:
74  const IPathFinderQuery* m_pathFinderQuery;
75 };
76 
77 
78 }
79 
#define BLOB_SET(blob, value)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:130
#define KyFloat32MAXVAL
KyFloat32 max value
Definition: types.h:71
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
PathFinderQueryBlob * 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
#define BLOB_STRING(str, src)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:166
std::uint8_t KyUInt8
uint8_t
Definition: types.h:27
#define KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68