gwnavruntime/queries/blobs/navtriangleblob.h Source File

navtriangleblob.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_NavTriangleBlob_H
9 #define Navigation_NavTriangleBlob_H
10 
15 
16 
17 namespace Kaim
18 {
19 
20 class NavTrianglePtr;
21 
22 // Blob to visual debug NavTriangle information.
23 class NavTriangleBlob
24 {
25 public:
26  enum ValidityStatus
27  {
28  VALID,
29  INVALID
30  };
31  NavTriangleBlob()
32  : m_floorIdx(NavFloorIdx_Invalid)
33  , m_triangleIdx(CompactNavTriangleIdx_MAXVAL)
34  , m_status((KyUInt16)INVALID)
35  {}
36 
37  ValidityStatus GetValidityStatus() const { return (ValidityStatus)m_status; }
38 
39  Triangle3f m_triangle;
40  CellPos m_cellPos; // The position of the cell that contains this triangle within the grid of PathData cells.
41  NavFloorIdx m_floorIdx;
42  CompactNavTriangleIdx m_triangleIdx;
43  KyUInt16 m_status;
44  NavTag m_navTag;
45 };
46 
47 inline void SwapEndianness(Kaim::Endianness::Target e, NavTriangleBlob& self)
48 {
49  SwapEndianness(e, self.m_triangle);
50  SwapEndianness(e, self.m_cellPos);
51  SwapEndianness(e, self.m_floorIdx);
52  SwapEndianness(e, self.m_triangleIdx);
53  SwapEndianness(e, self.m_status);
54  SwapEndianness(e, self.m_navTag);
55 }
56 
57 
58 class NavTriangleBlobBuilder : public BaseBlobBuilder<NavTriangleBlob>
59 {
60 public:
61  NavTriangleBlobBuilder(const NavTrianglePtr& trianglePtr) : m_trianglePtr(trianglePtr) {}
62 private:
63  void DoBuild()
64  {
65  if (IsWriteMode())
66  {
67  if (m_trianglePtr.IsValid() == false)
68  {
69  m_blob->m_status = (KyUInt16)NavTriangleBlob::INVALID;
70  return;
71  }
72 
73  m_blob->m_floorIdx = (NavFloorIdx)m_trianglePtr.GetNavFloor()->m_idxInTheNavCellBuffer;
74  m_blob->m_triangleIdx = (CompactNavTriangleIdx)m_trianglePtr.GetTriangleIdx();
75  m_blob->m_cellPos = m_trianglePtr.GetCellPos();
76  m_blob->m_status = (KyUInt16)NavTriangleBlob::VALID;
77  m_trianglePtr.GetVerticesPos3f(m_blob->m_triangle);
78  }
79 
80  if (m_trianglePtr.IsValid() == true)
81  {
82  BLOB_BUILD(m_blob->m_navTag, NavTagCopier(m_trianglePtr.GetNavTag()));
83  }
84  }
85 
86  NavTrianglePtr m_trianglePtr;
87 };
88 
89 }
90 
91 #endif // Kaim_NavTriangleBlob_H
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:33
#define BLOB_BUILD(blob, builder)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:189
static const NavFloorIdx NavFloorIdx_Invalid
Represents an invalid NavFloorIdx.
Definition: navmeshtypes.h:116
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
KyUInt32 NavFloorIdx
An index that uniquely identifies a single NavFloor within the set of NavFloors owned by a NavCell...
Definition: navmeshtypes.h:115
NavTriangleBlob * 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