gwnavruntime/abstractgraph/blobs/abstractgraphblob.h Source File

abstractgraphblob.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_AbstractGraphBlob_H
8 #define Navigation_AbstractGraphBlob_H
9 
13 
14 namespace Kaim
15 {
16 
17 
18 class AbstractGraphCellFloorIndices
19 {
20 public:
21  AbstractGraphCellFloorIndices() {}
22  AbstractGraphCellFloorIndices(CompactAbstractGraphCellIdx graphCellIdx, CompactAbstractGraphFloorIdx graphFloorIdx)
23  : m_abstractCellIdx(graphCellIdx), m_abstractFloorIdx(graphFloorIdx) {}
24 
25  CompactAbstractGraphCellIdx m_abstractCellIdx;
26  CompactAbstractGraphFloorIdx m_abstractFloorIdx;
27 };
28 
29 inline void SwapEndianness(Endianness::Target e, AbstractGraphCellFloorIndices& self)
30 {
31  SwapEndianness(e, self.m_abstractCellIdx);
32  SwapEndianness(e, self.m_abstractFloorIdx);
33 }
34 
35 
36 class AbstractGraphBlob
37 {
38  KY_ROOT_BLOB_CLASS(NavData, AbstractGraphBlob, 0)
39 public:
40 
41  bool IsCompatibleWith(const NavMeshGenParameters& genParameters) const;
42 
43  KyUInt32 GetNodeCount() const;
44 
45  Vec3f GetNodePosition(AbstractGraphNodeIdx graphNodeIdx, const DatabaseGenMetrics& genMetrics) const;
46 
47  KyFloat32 GetNeighborCost(AbstractGraphNodeIdx fromGraphNodeIdx, AbstractGraphNodeIdx toGraphNodeIdx) const;
48 
49 public: // internal
50  void GetVertexAndAltitude(AbstractGraphNodeIdx graphNodeIdx, NavVertex& graphNodeVertex, KyFloat32& altitude) const;
51 
52 public:
53  NavMeshGenParameters m_navMeshGenParameters;
54  GuidCompound m_navMeshGuidCompound;
55  CellBox m_cellBox;
56  BitFieldBlob m_cellBoxCoverage;
57  BlobArray<AbstractGraphCellFloorIndices> m_graphNodeIdxToGraphCellFloorIndices;
58 
59  BlobArray<KyFloat32> m_neighborCostsHalfMatrixBuffer;
60 
61  BlobArray< BlobRef<AbstractGraphCellBlob> > m_abstractCells;
62 };
63 
64 inline void SwapEndianness(Endianness::Target e, AbstractGraphBlob& self)
65 {
66  SwapEndianness(e, self.m_navMeshGenParameters);
67  SwapEndianness(e, self.m_navMeshGuidCompound);
68  SwapEndianness(e, self.m_cellBox);
69  SwapEndianness(e, self.m_graphNodeIdxToGraphCellFloorIndices);
70  SwapEndianness(e, self.m_neighborCostsHalfMatrixBuffer);
71  SwapEndianness(e, self.m_abstractCells);
72 }
73 
74 
75 
76 KY_INLINE bool AbstractGraphBlob::IsCompatibleWith(const NavMeshGenParameters& genParameters) const
77 {
78  return m_navMeshGenParameters == genParameters;
79 }
80 
81 KY_INLINE KyUInt32 AbstractGraphBlob::GetNodeCount() const
82 {
83  return m_graphNodeIdxToGraphCellFloorIndices.GetCount();
84 }
85 
86 KY_INLINE Vec3f AbstractGraphBlob::GetNodePosition(AbstractGraphNodeIdx graphNodeIdx, const DatabaseGenMetrics& genMetrics) const
87 {
88  const AbstractGraphCellFloorIndices& cellFloorIndices = m_graphNodeIdxToGraphCellFloorIndices.GetValues()[graphNodeIdx];
89  const AbstractGraphCellBlob* graphCellBlob = (m_abstractCells.GetValues()[cellFloorIndices.m_abstractCellIdx]).Ptr();
90  return graphCellBlob->GetPosition(graphNodeIdx, cellFloorIndices.m_abstractFloorIdx, genMetrics);
91 }
92 
93 
94 }
95 
96 
97 #endif
Box2i CellBox
A type that represents a bounding box around cells in a 2D grid.
Definition: navmeshtypes.h:34
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
Definition: gamekitcrowddispersion.h:20
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