gwnavruntime/navgraph/blobs/navgraphvertex.h Source File

navgraphvertex.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 
14 
15 namespace Kaim
16 {
17 
18 class NavGraphEdgeInfo
19 {
20  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
21 public:
22  NavGraphEdgeInfo() : m_navTagIdx(NavTagIdx_Invalid) {}
23  NavTagIdx m_navTagIdx;
24 };
25 inline void SwapEndianness(Endianness::Target e, NavGraphEdgeInfo& self)
26 {
27  SwapEndianness(e, self.m_navTagIdx);
28 }
29 
31 // NavGraphVertex
33 
34 /* This class represents a single vertex within a NavGraph */
35 class NavGraphVertex
36 {
37  KY_CLASS_WITHOUT_COPY(NavGraphVertex)
38 public:
39 
40  NavGraphVertex();
41 
42  // vertex data
43  KyUInt32 GetNeighborVertexCount() const;
44  const Vec3f& GetPosition() const;
45  NavTagIdx GetNavTagIdx() const;
46  NavGraphVertexLinkType GetLinkType() const;
47 
48  // edge data
49  NavGraphVertexIdx GetNeighborVertexIdx(KyUInt32 neighborIdx) const;
50  const NavGraphEdgeInfo& GetNavGraphEdgeInfo(KyUInt32 neighborIdx) const;
51  NavTagIdx GetNavGraphEdgeNavTagIdx(KyUInt32 neighborIdx) const;
52 
53 public:
54  Vec3f m_position;
55  NavTagIdx m_navTagIdx;
56  NavGraphVertexLinkType m_linkType;
57 
58  // Edges around this vertex
59  BlobArray<CompactNavGraphVertexIdx> m_neigbhorVertices; /*< Used internally to iterate through outgoing \NavGraphEdges. Do not modify. */
60  BlobArray<NavGraphEdgeInfo> m_edgesInfo;
61 };
62 inline void SwapEndianness(Endianness::Target e, NavGraphVertex& self)
63 {
64  SwapEndianness(e, self.m_position);
65  SwapEndianness(e, self.m_navTagIdx);
66  SwapEndianness(e, self.m_linkType);
67  SwapEndianness(e, self.m_neigbhorVertices);
68  SwapEndianness(e, self.m_edgesInfo);
69 }
70 
71 KY_INLINE NavGraphVertex::NavGraphVertex() : m_navTagIdx(NavTagIdx_Invalid), m_linkType(NavGraphVertexLinkType_LinkToNavMesh) {};
72 
73 KY_INLINE KyUInt32 NavGraphVertex::GetNeighborVertexCount() const { return m_neigbhorVertices.GetCount(); }
74 KY_INLINE const Vec3f& NavGraphVertex::GetPosition() const { return m_position; }
75 KY_INLINE NavTagIdx NavGraphVertex::GetNavTagIdx() const { return m_navTagIdx; }
76 KY_INLINE NavGraphVertexLinkType NavGraphVertex::GetLinkType() const { return m_linkType; }
77 
78 KY_INLINE NavGraphVertexIdx NavGraphVertex::GetNeighborVertexIdx(KyUInt32 neighborIdx) const
79 {
80  KY_ASSERT(neighborIdx < m_neigbhorVertices.GetCount());
81  return (NavGraphVertexIdx)m_neigbhorVertices.GetValues()[neighborIdx];
82 }
83 
84 KY_INLINE const NavGraphEdgeInfo& NavGraphVertex::GetNavGraphEdgeInfo(KyUInt32 neighborIdx) const
85 {
86  KY_ASSERT(neighborIdx < m_edgesInfo.GetCount());
87  return m_edgesInfo.GetValues()[neighborIdx];
88 }
89 
90 KY_INLINE NavTagIdx NavGraphVertex::GetNavGraphEdgeNavTagIdx(KyUInt32 neighborIdx) const { return GetNavGraphEdgeInfo(neighborIdx).m_navTagIdx; }
91 
92 } // namespace Kaim
93 
94 
95 
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:24
KyUInt32 NavGraphVertexIdx
An index that uniquely identifies a single vertex within the set of vertices owned by a NavGraph...
Definition: navgraphtypes.h:45
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
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:26
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17