gwnavruntime/abstractgraph/blobs/abstractgraphblob.h Source File

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