gwnavruntime/abstractgraph/blobs/abstractgraphfloorblob.h Source File

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