gwnavgeneration/navraster/navrastercell.h Source File

navrastercell.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 #pragma once
8 
18 
19 namespace Kaim
20 {
21 
22 inline KyUInt32 GetFeatureMask(KyUInt32 featureBitField, CardinalDir dir)
23 {
24  KyUInt32 bitshift = dir * 8;
25  return ((0xFF << bitshift) & featureBitField) >> bitshift;
26 }
27 
28 inline void AddFeatureMask(KyUInt32& featureBitField, CardinalDir dir, NavRasterFeatureMask feature)
29 {
30  featureBitField |= (feature << (dir * 8));
31 }
32 
33 class NavRasterPixel
34 {
35 public:
36  NavRasterPixel();
37 
38  KyUInt32 GetFeatureMask(CardinalDir dir) const { return Kaim::GetFeatureMask(m_featureBitField, dir); }
39  KyUInt32 GetNeighborFloorIndex(CardinalDir dir) const { return m_neighborFloorIdx[dir]; }
40 
41 public:
42  KyFloat32 m_altitude;
43  PixelColor m_floorColor;
44  KyUInt32 m_connexIdx;
45  KyUInt32 m_connectedComponentIdx;
46  KyUInt32 m_navTagIdx;
47  KyUInt32 m_featureBitField; // among NavRasterFeatureMask enum values
48 
49  // connections are indexed as follow:
50  // +-----------+
51  // | 1 |
52  // | |
53  // |2 + 0|
54  // | |
55  // | 3 |
56  // +-----------+
57  //0 corresponds to East (+1;0) and index increases CCW
58  //Stores level index of neighbor position if reachable, NavRaster_NoConnection otherwise
59  NavRasterFloorIdx m_neighborFloorIdx[4];
60 
61  KyUInt32 m_propagationId;
62 };
63 inline void SwapEndianness(Endianness::Target e, NavRasterPixel& self)
64 {
65  SwapEndianness(e, self.m_altitude);
66  SwapEndianness(e, self.m_floorColor);
67  SwapEndianness(e, self.m_connexIdx);
68  SwapEndianness(e, self.m_connectedComponentIdx);
69  SwapEndianness(e, self.m_navTagIdx);
70  SwapEndianness(e, self.m_featureBitField);
71  SwapEndianness(e, self.m_neighborFloorIdx[0]);
72  SwapEndianness(e, self.m_neighborFloorIdx[1]);
73  SwapEndianness(e, self.m_neighborFloorIdx[2]);
74  SwapEndianness(e, self.m_neighborFloorIdx[3]);
75  SwapEndianness(e, self.m_propagationId);
76 }
77 
78 class NavRasterColumn
79 {
80  KY_CLASS_WITHOUT_COPY(NavRasterColumn);
81 public:
82  NavRasterColumn() {}
83 
84  BlobArray<NavRasterPixel> m_navRasterPoints;
85 };
86 inline void SwapEndianness(Endianness::Target e, NavRasterColumn& self)
87 {
88  SwapEndianness(e, self.m_navRasterPoints);
89 }
90 
91 
92 class NavRasterCell
93 {
94  KY_ROOT_BLOB_CLASS(Generator, NavRasterCell, 1)
95 public:
96  KyFloat32 m_rasterPrecision;
97  PixelAndCellGrid m_pixelAndCellGrid;
98  CellDesc m_cellDesc;
99  BlobArray<NavRasterColumn> m_columns; // row major
100 };
101 inline void SwapEndianness(Endianness::Target e, NavRasterCell& self)
102 {
103  SwapEndianness(e, self.m_rasterPrecision);
104  SwapEndianness(e, self.m_pixelAndCellGrid);
105  SwapEndianness(e, self.m_cellDesc);
106  SwapEndianness(e, self.m_columns);
107 }
108 
109 KY_INLINE NavRasterPixel::NavRasterPixel()
110  : m_altitude(0.f)
111  , m_floorColor(PixelColor_Unset)
112  , m_connexIdx(KyUInt32MAXVAL)
113  , m_connectedComponentIdx(KyUInt32MAXVAL)
114  , m_navTagIdx(KyUInt32MAXVAL)
115  , m_featureBitField(0)
116  , m_propagationId(KyUInt32MAXVAL)
117 {
118  for (KyUInt32 i = 0; i < 4; ++i)
119  m_neighborFloorIdx[i] = NavRasterFloorIdx_Invalid;
120 }
121 
122 
123 }
124 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
KyUInt32 CardinalDir
Defines a type that refers to one of the cardinal points on the compass:
Definition: cardinaldir.h:15
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
#define KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68
float KyFloat32
float
Definition: types.h:32