gwnavruntime/path/pathblob.h Source File

pathblob.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 // primary contact: GUAL - secondary contact: NOBODY
9 #ifndef Navigation_PathBlob_H
10 #define Navigation_PathBlob_H
11 
15 #include "gwnavruntime/path/path.h"
18 
19 namespace Kaim
20 {
21 
22 class PathBlob
23 {
24  KY_ROOT_BLOB_CLASS(Runtime, PathBlob, 1)
25 
26 public:
27  PathBlob() : m_pathDist(KyFloat32MAXVAL), m_pathCost(KyFloat32MAXVAL) {}
28  KyUInt32 m_visualDebugId;
29  KyFloat32 m_pathDist;
30  KyFloat32 m_pathCost;
31  BlobArray<Vec3f> m_nodePositions;
32  BlobRef<ChannelArrayBlob> m_channelArrayBlob;
33 };
34 inline void SwapEndianness(Endianness::Target e, PathBlob& self)
35 {
36  SwapEndianness(e, self.m_visualDebugId);
37  SwapEndianness(e, self.m_pathDist);
38  SwapEndianness(e, self.m_pathCost);
39  SwapEndianness(e, self.m_nodePositions);
40  SwapEndianness(e, self.m_channelArrayBlob);
41 }
42 
43 
44 class PathBlobBuilder: public BaseBlobBuilder<PathBlob>
45 {
46  KY_CLASS_WITHOUT_COPY(PathBlobBuilder)
47 
48 public:
49  PathBlobBuilder(const Path* path): m_path(path), m_visualDebugId(0) {}
50  ~PathBlobBuilder() {}
51 
52 private:
53  virtual void DoBuild()
54  {
55  BLOB_SET(m_blob->m_visualDebugId, m_visualDebugId);
56  if (m_path != NULL && m_path->GetNodeCount() > 0)
57  {
58  BLOB_SET(m_blob->m_pathDist, m_path->GetPathDistance());
59  BLOB_SET(m_blob->m_pathCost, m_path->GetPathCost());
60 
61  Vec3f* nodePositions = BLOB_ARRAY(m_blob->m_nodePositions, m_path->GetNodeCount());
62 
63  if (IsWriteMode())
64  {
65  for (KyUInt32 i = 0; i < m_path->GetNodeCount(); ++i)
66  nodePositions[i] = m_path->GetNodePosition(i);
67  }
68  }
69  /*else
70  {
71  BLOB_ARRAY(m_blob->m_nodePositions, 0);
72  }*/
73  if((m_path != KY_NULL) && (m_path->m_channelArray != KY_NULL))
74  BUILD_REFERENCED_BLOB(m_blob->m_channelArrayBlob, ChannelArrayBlobBuilder(m_path->m_channelArray, m_visualDebugId));
75  }
76 
77 public:
78  const Path* m_path;
79  KyUInt32 m_visualDebugId;
80 };
81 
82 
83 }
84 
85 #endif
#define BLOB_SET(blob, value)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:136
#define KyFloat32MAXVAL
The maximum value that can be stored in the KyFloat32 variable type.
Definition: types.h:227
#define KY_NULL
Null value.
Definition: types.h:247
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
PathBlob * m_blob
The blob maintained by this builder. Only modify using the macros listed under DoBuild().
Definition: baseblobbuilder.h:117
Definition: gamekitcrowddispersion.h:20
bool IsWriteMode()
Indicates whether the builder is operating in COUNT mode or in WRITE mode.
Definition: baseblobbuilder.h:47
#define BLOB_ARRAY(blobArray, count)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:147
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
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