gwnavruntime/path/pathblob.h Source File

pathblob.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 
13 #include "gwnavruntime/path/path.h"
16 
17 namespace Kaim
18 {
19 
20 class PathBlob
21 {
22  KY_ROOT_BLOB_CLASS(Runtime, PathBlob, 1)
23 
24 public:
25  PathBlob() : m_visualDebugId(KyUInt32MAXVAL), m_pathDist(KyFloat32MAXVAL), m_pathCost(KyFloat32MAXVAL) {}
26  KyUInt32 m_visualDebugId;
27  KyFloat32 m_pathDist;
28  KyFloat32 m_pathCost;
29  BlobArray<Vec3f> m_nodePositions;
30  BlobRef<ChannelArrayBlob> m_channelArrayBlob;
31 };
32 inline void SwapEndianness(Endianness::Target e, PathBlob& self)
33 {
34  SwapEndianness(e, self.m_visualDebugId);
35  SwapEndianness(e, self.m_pathDist);
36  SwapEndianness(e, self.m_pathCost);
37  SwapEndianness(e, self.m_nodePositions);
38  SwapEndianness(e, self.m_channelArrayBlob);
39 }
40 
41 
42 class PathBlobBuilder: public BaseBlobBuilder<PathBlob>
43 {
44  KY_CLASS_WITHOUT_COPY(PathBlobBuilder)
45 
46 public:
47  PathBlobBuilder(const Path* path): m_path(path), m_visualDebugId(0) {}
48  ~PathBlobBuilder() {}
49 
50 private:
51  virtual void DoBuild()
52  {
53  BLOB_SET(m_blob->m_visualDebugId, m_visualDebugId);
54  if (m_path != NULL && m_path->GetNodeCount() > 0)
55  {
56  BLOB_SET(m_blob->m_pathDist, m_path->GetPathDistance());
57  BLOB_SET(m_blob->m_pathCost, m_path->GetPathCost());
58 
59  Vec3f* nodePositions = BLOB_ARRAY(m_blob->m_nodePositions, m_path->GetNodeCount());
60 
61  if (IsWriteMode())
62  {
63  for (KyUInt32 i = 0; i < m_path->GetNodeCount(); ++i)
64  nodePositions[i] = m_path->GetNodePosition(i);
65  }
66  }
67  /*else
68  {
69  BLOB_ARRAY(m_blob->m_nodePositions, 0);
70  }*/
71  if((m_path != nullptr) && (m_path->m_channelArray != nullptr))
72  BUILD_REFERENCED_BLOB(m_blob->m_channelArrayBlob, ChannelArrayBlobBuilder(m_path->m_channelArray, m_visualDebugId));
73  }
74 
75 public:
76  const Path* m_path;
77  KyUInt32 m_visualDebugId;
78 };
79 
80 
81 }
82 
#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
PathBlob * 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
bool IsWriteMode()
Indicates whether the builder is operating in COUNT mode or in WRITE mode.
Definition: baseblobbuilder.h:43
#define BLOB_ARRAY(blobArray, count)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:139
#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