gwnavruntime/queries/blobs/navtriangleblob.h Source File

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