gwnavruntime/queries/blobs/navhalfedgeblob.h Source File

navhalfedgeblob.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 
8 #pragma once
9 
13 
14 
15 namespace Kaim
16 {
17 
18 class NavHalfEdgePtr;
19 
20 // Blob to visual debug NavTriangle information.
21 class NavHalfEdgeBlob
22 {
23 public:
24  enum ValidityStatus
25  {
26  VALID,
27  INVALID
28  };
29 
30  NavHalfEdgeBlob()
31  : m_halfEdgeIdx(CompactNavHalfEdgeIdx_MAXVAL)
32  , m_status((KyUInt16)INVALID)
33  {}
34 
35  ValidityStatus GetValidityStatus() const { return (ValidityStatus)m_status; }
36 
37  Vec3f m_startPos3f;
38  Vec3f m_endPos3f;
39  CellPos m_cellPos; // The position of the cell that contains this triangle within the grid of PathData cells.
40  CompactNavHalfEdgeIdx m_halfEdgeIdx;
41  KyUInt16 m_status;
42 };
43 
44 inline void SwapEndianness(Kaim::Endianness::Target e, NavHalfEdgeBlob& self)
45 {
46  SwapEndianness(e, self.m_startPos3f);
47  SwapEndianness(e, self.m_endPos3f);
48  SwapEndianness(e, self.m_cellPos);
49  SwapEndianness(e, self.m_halfEdgeIdx);
50  SwapEndianness(e, self.m_status);
51 }
52 
53 
54 class NavHalfEdgeBlobBuilder : public BaseBlobBuilder<NavHalfEdgeBlob>
55 {
56 public:
57  NavHalfEdgeBlobBuilder(const NavHalfEdgePtr& halfEdgePtr) : m_halfEdgePtr(halfEdgePtr) {}
58 private:
59  void DoBuild()
60  {
61  if (IsWriteMode())
62  {
63  if (m_halfEdgePtr.IsValid() == false)
64  {
65  m_blob->m_status = (KyUInt16)NavHalfEdgeBlob::INVALID;
66  return;
67  }
68 
69  m_blob->m_halfEdgeIdx = (CompactNavHalfEdgeIdx)m_halfEdgePtr.GetHalfEdgeIdx();
70  m_blob->m_cellPos = m_halfEdgePtr.GetCellPos();
71  m_blob->m_status = (KyUInt16)NavHalfEdgeBlob::VALID;
72  m_halfEdgePtr.GetVerticesPos3f(m_blob->m_startPos3f, m_blob->m_endPos3f);
73  }
74  }
75 
76  NavHalfEdgePtr m_halfEdgePtr;
77 };
78 }
79 
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:30
std::uint16_t KyUInt16
uint16_t
Definition: types.h:28
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
NavHalfEdgeBlob * m_blob
The blob maintained by this builder. Only modify using the macros listed under DoBuild().
Definition: baseblobbuilder.h:113
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
bool IsWriteMode()
Indicates whether the builder is operating in COUNT mode or in WRITE mode.
Definition: baseblobbuilder.h:43