gwnavruntime/abstractgraph/blobs/abstractgraphfloorblob.h Source File

abstractgraphfloorblob.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 #ifndef Navigation_AbstractGraphFloorBlob_H
8 #define Navigation_AbstractGraphFloorBlob_H
9 
10 
15 
16 
17 namespace Kaim
18 {
19 
20 class AbstractGraphFloorBlob
21 {
22  KY_ROOT_BLOB_CLASS(NavData, AbstractGraphFloorBlob, 0)
23 public:
24  AbstractGraphFloorBlob();
25 
26 public:
27  KyUInt32 GetLocalNodeIdx(AbstractGraphNodeIdx graphNodeIdx) const;
28  KyUInt32 GetNodeIdx(KyUInt32 localNodeIdx) const;
29 
30  const AbstractGraphVertex& GetAbstractGraphVertex(AbstractGraphNodeIdx graphNodeIdx) const;
31  KyFloat32 GetAltitude(AbstractGraphNodeIdx graphNodeIdx) const;
32  CardinalDir GetCellBoundaryDir(AbstractGraphNodeIdx graphNodeIdx) const;
33 
34  const AbstractGraphVertex& GetAbstractGraphVertexFromLocalIdx(KyUInt32 localIdx) const;
35  KyFloat32 GetAltitudeFromLocalIdx(KyUInt32 localIdx) const;
36  CardinalDir GetCellBoundaryDirFromLocalIdx(KyUInt32 localNodeIdx) const;
37 
38 
39 public:
40  NavFloorIdx m_originalNavFloorIdx;
41 
42  AbstractGraphNodeIdx m_abstractGraphNodeFirstIdx;
43  KyUInt16 m_firstIdxForCellBoundaryDir[4];
44  KyUInt16 m_countForCellBoundaryDir[4];
45  BlobArray<KyFloat32> m_altitudes;
46  BlobArray<AbstractGraphVertex> m_nodeVertices; // Note that nodes are sorted along the Y axis for EAST and WEST cell boundaries, or the X axis for NORTH and SOUTH cell boundaries
47 };
48 
49 inline void SwapEndianness(Endianness::Target e, AbstractGraphFloorBlob& self)
50 {
51  SwapEndianness(e, self.m_originalNavFloorIdx);
52  SwapEndianness(e, self.m_abstractGraphNodeFirstIdx);
53  SwapEndianness(e, self.m_firstIdxForCellBoundaryDir[0]);
54  SwapEndianness(e, self.m_firstIdxForCellBoundaryDir[1]);
55  SwapEndianness(e, self.m_firstIdxForCellBoundaryDir[2]);
56  SwapEndianness(e, self.m_firstIdxForCellBoundaryDir[3]);
57  SwapEndianness(e, self.m_countForCellBoundaryDir[0]);
58  SwapEndianness(e, self.m_countForCellBoundaryDir[1]);
59  SwapEndianness(e, self.m_countForCellBoundaryDir[2]);
60  SwapEndianness(e, self.m_countForCellBoundaryDir[3]);
61  SwapEndianness(e, self.m_altitudes);
62  SwapEndianness(e, self.m_nodeVertices);
63 }
64 
65 
66 KY_INLINE KyUInt32 AbstractGraphFloorBlob::GetNodeIdx(KyUInt32 localNodeIdx) const
67 {
68  return localNodeIdx + m_abstractGraphNodeFirstIdx;
69 }
70 
71 KY_INLINE KyUInt32 AbstractGraphFloorBlob::GetLocalNodeIdx(AbstractGraphNodeIdx graphNodeIdx) const
72 {
73  KY_ASSERT(graphNodeIdx >= m_abstractGraphNodeFirstIdx);
74  KY_ASSERT(graphNodeIdx < (m_abstractGraphNodeFirstIdx + m_countForCellBoundaryDir[0] + m_countForCellBoundaryDir[1] + m_countForCellBoundaryDir[2] + m_countForCellBoundaryDir[3]));
75  return graphNodeIdx - m_abstractGraphNodeFirstIdx;
76 }
77 
78 KY_INLINE const AbstractGraphVertex& AbstractGraphFloorBlob::GetAbstractGraphVertex(AbstractGraphNodeIdx graphNodeIdx) const
79 {
80  return GetAbstractGraphVertexFromLocalIdx(GetLocalNodeIdx(graphNodeIdx));
81 }
82 
83 KY_INLINE KyFloat32 AbstractGraphFloorBlob::GetAltitude(AbstractGraphNodeIdx graphNodeIdx) const
84 {
85  return GetAltitudeFromLocalIdx(GetLocalNodeIdx(graphNodeIdx));
86 }
87 
88 KY_INLINE const AbstractGraphVertex& AbstractGraphFloorBlob::GetAbstractGraphVertexFromLocalIdx(KyUInt32 localIdx) const
89 {
90  return m_nodeVertices.GetValues()[localIdx];
91 }
92 
93 KY_INLINE KyFloat32 AbstractGraphFloorBlob::GetAltitudeFromLocalIdx(KyUInt32 localIdx) const
94 {
95  return m_altitudes.GetValues()[localIdx];
96 }
97 
98 KY_INLINE CardinalDir AbstractGraphFloorBlob::GetCellBoundaryDir(AbstractGraphNodeIdx graphNodeIdx) const
99 {
100  return GetCellBoundaryDirFromLocalIdx(GetLocalNodeIdx(graphNodeIdx));
101 }
102 
103 }
104 
105 
106 #endif
KyUInt32 CardinalDir
Defines a type that refers to one of the cardinal points on the compass:
Definition: cardinaldir.h:23
KyUInt32 NavFloorIdx
An index that uniquely identifies a single NavFloor within the set of NavFloors owned by a NavCell...
Definition: navmeshtypes.h:115
Definition: gamekitcrowddispersion.h:20
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
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43