gwnavruntime/navgraph/navgraphtypes.h Source File

navgraphtypes.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 
11 
12 namespace Kaim
13 {
14 
15 // This enum is used in some functions coming with a NavGraphEdgeRawPtr or a NavGraphEdgePtr to tell whether or not
16 // the opposite NavGraphEdge (going from endPos to startPos in the same navGraph) should be also considered if it exists.
17 enum NavGraphEdgeDirection
18 {
19  NAVGRAPHEDGE_MONODIRECTIONAL = 0,
20  NAVGRAPHEDGE_BIDIRECTIONAL = 1
21 };
22 
25 static const NavGraphVertexLinkType NavGraphVertexLinkType_NoLink = 0;
26 static const NavGraphVertexLinkType NavGraphVertexLinkType_LinkToNavMesh = 1;
27 
28 typedef KyUInt16 NavGraphVertexType;
29 static const NavGraphVertexType NavGraphVertexType_Unset = 0;
30 static const NavGraphVertexType NavGraphVertexType_InGraphVertex = 1;
31 static const NavGraphVertexType NavGraphVertexType_AddedVertexForFromOutsideLink = 2;
32 
33 
34 // index of a StitchedGraph in the buffer of ActiveData
35 typedef KyInt32 NavGraphIdxInActiveData;
36 static const NavGraphIdxInActiveData NavGraphIdxInActiveData_Invalid = KyInt32MAXVAL;
37 
38 typedef KyUInt16 CompactNavGraphVertexIdx;
39 static const CompactNavGraphVertexIdx CompactNavGraphVertexIdx_MAXVAL = 0xFFFF;
40 
41 typedef KyUInt16 CompactNavGraphNeighborIdx;
42 static const CompactNavGraphNeighborIdx CompactNavGraphNeighborIdx_MAXVAL = 0xFFFF;
43 
44 // vertex Index in the NavGraph
46 static const NavGraphVertexIdx NavGraphVertexIdx_Invalid = (NavGraphVertexIdx)CompactNavGraphVertexIdx_MAXVAL;
47 
48 struct NavGraphEdgeSmartIdx
49 {
50  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
51 public:
52  NavGraphEdgeSmartIdx() : m_startVertexIdx(CompactNavGraphVertexIdx_MAXVAL), m_neighborIdx(CompactNavGraphNeighborIdx_MAXVAL) {}
53  NavGraphEdgeSmartIdx(const NavGraphEdgeSmartIdx& smartIdx) : m_startVertexIdx(smartIdx.m_startVertexIdx), m_neighborIdx(smartIdx.m_neighborIdx) {}
54  NavGraphEdgeSmartIdx(NavGraphVertexIdx startVertexIdx, KyUInt32 neighborIdx) : m_startVertexIdx((CompactNavGraphVertexIdx)startVertexIdx), m_neighborIdx((CompactNavGraphNeighborIdx)neighborIdx) {}
55 
56  bool IsValid() const;
57  void Invalidate();
58 
59  bool operator < (const NavGraphEdgeSmartIdx& rhs) const;
60  bool operator ==(const NavGraphEdgeSmartIdx& rhs) const;
61 
62  NavGraphVertexIdx GetStartVertexIdx() const;
63  KyUInt32 GetNeighborVertexIdx() const;
64 public:
65  CompactNavGraphVertexIdx m_startVertexIdx;
66  CompactNavGraphNeighborIdx m_neighborIdx;
67 };
68 
69 KY_INLINE NavGraphVertexIdx NavGraphEdgeSmartIdx::GetStartVertexIdx() const { return (NavGraphVertexIdx)m_startVertexIdx; }
70 KY_INLINE KyUInt32 NavGraphEdgeSmartIdx::GetNeighborVertexIdx() const { return (KyUInt32)m_neighborIdx; }
71 KY_INLINE bool NavGraphEdgeSmartIdx::IsValid() const { return m_startVertexIdx != CompactNavGraphVertexIdx_MAXVAL && m_neighborIdx != CompactNavGraphNeighborIdx_MAXVAL;}
72 KY_INLINE void NavGraphEdgeSmartIdx::Invalidate() { m_startVertexIdx = CompactNavGraphVertexIdx_MAXVAL; m_neighborIdx = CompactNavGraphNeighborIdx_MAXVAL; }
73 
74 KY_INLINE bool NavGraphEdgeSmartIdx::operator < (const NavGraphEdgeSmartIdx& rhs) const
75 {
76  return GetStartVertexIdx() < rhs.GetStartVertexIdx() || (GetStartVertexIdx() == rhs.GetStartVertexIdx() && GetNeighborVertexIdx() < rhs.GetNeighborVertexIdx());
77 }
78 KY_INLINE bool NavGraphEdgeSmartIdx::operator ==(const NavGraphEdgeSmartIdx& rhs) const
79 {
80  return GetStartVertexIdx() == rhs.GetStartVertexIdx() && GetNeighborVertexIdx() == rhs.GetNeighborVertexIdx();
81 }
82 
83 } // namespace Kaim
84 
85 
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
static const NavGraphVertexIdx NavGraphVertexIdx_Invalid
Represents an invalid NavGraphVertexIdx.
Definition: navgraphtypes.h:46
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
static const NavGraphVertexLinkType NavGraphVertexLinkType_NoLink
Indicates that this vertex should not be connected to the NavMesh.
Definition: navgraphtypes.h:25
std::uint16_t KyUInt16
uint16_t
Definition: types.h:28
#define KyInt32MAXVAL
KyInt32 max value
Definition: types.h:60
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
std::int32_t KyInt32
int32_t
Definition: types.h:24