gwnavruntime/navgraph/blobs/navgraphvertex.h Source File

navgraphvertex.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: JUBA - secondary contact: NOBODY
9 #ifndef Navigation_NavGraphVertex_H
10 #define Navigation_NavGraphVertex_H
11 
15 
16 
17 namespace Kaim
18 {
19 
20 class NavGraphEdgeInfo
21 {
22  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
23 public:
24  NavGraphEdgeInfo() : m_navTagIdx(NavTagIdx_Invalid) {}
25  NavTagIdx m_navTagIdx;
26 };
27 inline void SwapEndianness(Endianness::Target e, NavGraphEdgeInfo& self)
28 {
29  SwapEndianness(e, self.m_navTagIdx);
30 }
31 
33 // NavGraphVertex
35 
36 /* This class represents a single vertex within a NavGraph */
37 class NavGraphVertex
38 {
39  KY_CLASS_WITHOUT_COPY(NavGraphVertex)
40 public:
41 
42  NavGraphVertex();
43 
44  // vertex data
45  KyUInt32 GetNeighborVertexCount() const;
46  const Vec3f& GetPosition() const;
47  NavTagIdx GetNavTagIdx() const;
48  NavGraphVertexLinkType GetLinkType() const;
49 
50  // edge data
51  NavGraphVertexIdx GetNeighborVertexIdx(KyUInt32 neighborIdx) const;
52  const NavGraphEdgeInfo& GetNavGraphEdgeInfo(KyUInt32 neighborIdx) const;
53  NavTagIdx GetNavGraphEdgeNavTagIdx(KyUInt32 neighborIdx) const;
54 
55 public:
56  Vec3f m_position;
57  NavTagIdx m_navTagIdx;
58  NavGraphVertexLinkType m_linkType;
59 
60  // Edges around this vertex
61  BlobArray<CompactNavGraphVertexIdx> m_neigbhorVertices; /*< Used internally to iterate through outgoing \NavGraphEdges. Do not modify. */
62  BlobArray<NavGraphEdgeInfo> m_edgesInfo;
63 };
64 inline void SwapEndianness(Endianness::Target e, NavGraphVertex& self)
65 {
66  SwapEndianness(e, self.m_position);
67  SwapEndianness(e, self.m_navTagIdx);
68  SwapEndianness(e, self.m_linkType);
69  SwapEndianness(e, self.m_neigbhorVertices);
70  SwapEndianness(e, self.m_edgesInfo);
71 }
72 
73 KY_INLINE NavGraphVertex::NavGraphVertex() : m_navTagIdx(NavTagIdx_Invalid), m_linkType(NavGraphVertexLinkType_LinkToNavMesh) {};
74 
75 KY_INLINE KyUInt32 NavGraphVertex::GetNeighborVertexCount() const { return m_neigbhorVertices.GetCount(); }
76 KY_INLINE const Vec3f& NavGraphVertex::GetPosition() const { return m_position; }
77 KY_INLINE NavTagIdx NavGraphVertex::GetNavTagIdx() const { return m_navTagIdx; }
78 KY_INLINE NavGraphVertexLinkType NavGraphVertex::GetLinkType() const { return m_linkType; }
79 
80 KY_INLINE NavGraphVertexIdx NavGraphVertex::GetNeighborVertexIdx(KyUInt32 neighborIdx) const
81 {
82  KY_ASSERT(neighborIdx < m_neigbhorVertices.GetCount());
83  return (NavGraphVertexIdx)m_neigbhorVertices.GetValues()[neighborIdx];
84 }
85 
86 KY_INLINE const NavGraphEdgeInfo& NavGraphVertex::GetNavGraphEdgeInfo(KyUInt32 neighborIdx) const
87 {
88  KY_ASSERT(neighborIdx < m_edgesInfo.GetCount());
89  return m_edgesInfo.GetValues()[neighborIdx];
90 }
91 
92 KY_INLINE NavTagIdx NavGraphVertex::GetNavGraphEdgeNavTagIdx(KyUInt32 neighborIdx) const { return GetNavGraphEdgeInfo(neighborIdx).m_navTagIdx; }
93 
94 } // namespace Kaim
95 
96 
97 #endif // Navigation_NavGraphVertex_H
98 
KyUInt16 NavGraphVertexLinkType
Defines a type for a tag that determines whether or not a vertex in a NavGraph should be connected to...
Definition: navgraphtypes.h:26
KyUInt32 NavGraphVertexIdx
An index that uniquely identifies a single vertex within the set of vertices owned by a NavGraph...
Definition: navgraphtypes.h:47
static const NavGraphVertexLinkType NavGraphVertexLinkType_LinkToNavMesh
Indicates that this vertex should be connected to the NavMesh. If the vertex is outside, we try to link it inside.
Definition: navgraphtypes.h:28
#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
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36