gwnavruntime/navgraph/navgraphtypes.h Source File

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