gwnavruntime/navmesh/blobs/stitch1To1datablob.h Source File

stitch1To1datablob.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 namespace Kaim
15 {
16 
17 class Stitch1To1Edge
18 {
19  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
20 public:
21  Stitch1To1Edge() {}
22  KY_INLINE KyUInt32 GetStartVertexIdx() const { return (KyUInt32) (m_edgeData & 0x00000FFF) ; }
23  KY_INLINE KyUInt32 GetEndVertexIdx() const { return (KyUInt32)((m_edgeData & 0x00FFF000) >> 12); }
24  KY_INLINE NavHalfEdgeType GetHalfEdgeType() const { return (NavHalfEdgeType)(m_edgeData >> 29); }
25  /* BitField
26  bit 0 - 11 -> 12 bits : StartVertexIdx
27  bit 12 - 23 -> 12 bits : EndVertexIdx
28  bit 24 - 28 -> 5 bits : unused
29  bit 29 - 31 -> 3 bits : NavHalfEdgeType
30  */
31  KyUInt32 m_edgeData;
32 };
33 KY_INLINE void SwapEndianness(Endianness::Target e, Stitch1To1Edge& self)
34 {
35  SwapEndianness(e, self.m_edgeData);
36 }
37 
38 // 1 per "meta" floor -> the generation tag-free navfloor, the generation tag-full navfloor
39 // and the runtime dynamic navFloor share the same
40 class NavFloor1To1StitchDataBlob
41 {
42  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
43 public:
44  NavFloor1To1StitchDataBlob()
45  {
46  m_firstIdxOfEdgeForType[0] = 0;
47  m_firstIdxOfEdgeForType[1] = 0;
48  m_firstIdxOfEdgeForType[2] = 0;
49  m_firstIdxOfEdgeForType[3] = 0;
50  m_firstIdxOfEdgeForType[4] = 0;
51  m_edgeCountForType[0] = 0;
52  m_edgeCountForType[1] = 0;
53  m_edgeCountForType[2] = 0;
54  m_edgeCountForType[3] = 0;
55  m_edgeCountForType[4] = 0;
56  }
57  // store the edges coming from the tag-free navfloor version of type
58  // EDGETYPE_CELLBOUNDARY_EAST, EDGETYPE_CELLBOUNDARY_NORTH, EDGETYPE_CELLBOUNDARY_WEST , EDGETYPE_CELLBOUNDARY_SOUTH, EDGETYPE_FLOORBOUNDARY
59  // Stitch1To1Edge are sorted differently depending upon the edge type:
60  // EDGETYPE_CELLBOUNDARY_EAST or EDGETYPE_CELLBOUNDARY_WEST : sorted along Y axis
61  // EDGETYPE_CELLBOUNDARY_NORTH or EDGETYPE_CELLBOUNDARY_SOUTH : sorted along X axis
62  // EDGETYPE_FLOORBOUNDARY : sorted along X and Y, cf Vec2i::operator<()
63 
64  KyUInt16 m_firstIdxOfEdgeForType[5]; // see NavHalfEdgeType
65  KyUInt16 m_edgeCountForType[5]; // see NavHalfEdgeType
66  BlobArray<Stitch1To1Edge> m_stitch1To1Edges;
67  BlobArray<NavVertex> m_navVertices;
68  BlobArray<KyFloat32> m_navVertexAltitudes;
69 };
70 KY_INLINE void SwapEndianness(Endianness::Target e, NavFloor1To1StitchDataBlob& self)
71 {
72  SwapEndianness(e, self.m_firstIdxOfEdgeForType[0]);
73  SwapEndianness(e, self.m_firstIdxOfEdgeForType[1]);
74  SwapEndianness(e, self.m_firstIdxOfEdgeForType[2]);
75  SwapEndianness(e, self.m_firstIdxOfEdgeForType[3]);
76  SwapEndianness(e, self.m_firstIdxOfEdgeForType[4]);
77  SwapEndianness(e, self.m_edgeCountForType[0]);
78  SwapEndianness(e, self.m_edgeCountForType[1]);
79  SwapEndianness(e, self.m_edgeCountForType[2]);
80  SwapEndianness(e, self.m_edgeCountForType[3]);
81  SwapEndianness(e, self.m_edgeCountForType[4]);
82  SwapEndianness(e, self.m_stitch1To1Edges);
83  SwapEndianness(e, self.m_navVertices);
84  SwapEndianness(e, self.m_navVertexAltitudes);
85 }
86 
87 
88 class Stitch1To1ToHalfEdgeInFloor
89 {
90  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
91 public:
92  Stitch1To1ToHalfEdgeInFloor() : m_hasDifferentLinkFromStitch1To1Edge(0) {}
93 
94  KyUInt32 GetNavFloorLinkCount() const { return m_dynamicNavFloorEdgeIdx.GetCount(); }
95  KyUInt32 GetStitch1To1EdgeCount() const { return m_stitch1To1EdgeIdxToFirstIdx.GetCount(); }
96 
97  // NavHalfEdgeIdx to Stitch1To1EdgeIdx
98  BlobArray<KyUInt16> m_stitch1To1EdgeIdx; // count = total of NavHalfEdge in dynamic navFloor that are on FloorLink. Accessed by NavHalfEdge::GetBoundaryEdgeIdx()
99 
100  // Stitch1To1EdgeIdx to NavHalfEdgeIdx
101  BlobArray<CompactNavHalfEdgeIdx> m_dynamicNavFloorEdgeIdx; // count=total of HalfEdge in dynamicFloor that are on FloorLink. Accessed by NavHalfEdge::GetBoundaryEdgeIdx()
102  BlobArray<KyUInt16> m_stitch1To1EdgeIdxToFirstIdx; // count == number of Stitch1To1Edge == sizeof(m_stitch1To1Edges) in corresponding NavFloor1To1StitchData
103  BlobArray<KyUInt16> m_stitch1To1EdgeIdxToCount; // count == number of Stitch1To1Edge == sizeof(m_stitch1To1Edges) in corresponding NavFloor1To1StitchData
104  KyUInt8 m_hasDifferentLinkFromStitch1To1Edge; // 0 or 1
105 };
106 
107 KY_INLINE void SwapEndianness(Endianness::Target e, Stitch1To1ToHalfEdgeInFloor& self)
108 {
109  SwapEndianness(e, self.m_stitch1To1EdgeIdx);
110  SwapEndianness(e, self.m_dynamicNavFloorEdgeIdx);
111  SwapEndianness(e, self.m_stitch1To1EdgeIdxToFirstIdx);
112  SwapEndianness(e, self.m_stitch1To1EdgeIdxToCount);
113  SwapEndianness(e, self.m_hasDifferentLinkFromStitch1To1Edge);
114 }
115 
116 }
117 
118 
119 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
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
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
NavHalfEdgeType
Enumerates the possible types of boundary that can be represented by a NavHalfEdge.
Definition: navmeshtypes.h:49
std::uint8_t KyUInt8
uint8_t
Definition: types.h:27