gwnavruntime/navmesh/blobs/stitch1To1datablob.h Source File

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