gwnavruntime/queries/blobs/navhalfedgeblob.h Source File

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