gwnavgeneration/navraster/navrastercell.h Source File

navrastercell.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: LASI - secondary contact: GUAL
9 #ifndef GwNavGen_NavRasterCell_H
10 #define GwNavGen_NavRasterCell_H
11 
12 
22 
23 namespace Kaim
24 {
25 class NavRasterPixel
26 {
27 public:
28  NavRasterPixel();
29 
30  KyUInt32 GetFeatureMask(CardinalDir dir) const;
31  KyUInt32 GetNeighborFloorIndex(CardinalDir dir) const;
32 
33 public:
34  KyFloat32 m_altitude;
35  PixelColor m_floorColor;
36  KyUInt32 m_connexIdx;
37  KyUInt32 m_connectedComponentIdx;
38  KyUInt32 m_navTagIdx;
39  KyUInt32 m_featureBitField; // among NavRasterFeatureMask enum values
40 
41  // connections are indexed as follow:
42  // +-----------+
43  // | 1 |
44  // | |
45  // |2 + 0|
46  // | |
47  // | 3 |
48  // +-----------+
49  //0 corresponds to East (+1;0) and index increases CCW
50  //Stores level index of neighbor position if reachable, NavRaster_NoConnection otherwise
51  NavRasterFloorIdx m_neighborFloorIdx[4];
52 
53  KyUInt32 m_currentPropagationId;
54 };
55 inline void SwapEndianness(Endianness::Target e, NavRasterPixel& self)
56 {
57  SwapEndianness(e, self.m_altitude);
58  SwapEndianness(e, self.m_floorColor);
59  SwapEndianness(e, self.m_connexIdx);
60  SwapEndianness(e, self.m_navTagIdx);
61  SwapEndianness(e, self.m_connectedComponentIdx);
62  SwapEndianness(e, self.m_neighborFloorIdx[0]);
63  SwapEndianness(e, self.m_neighborFloorIdx[1]);
64  SwapEndianness(e, self.m_neighborFloorIdx[2]);
65  SwapEndianness(e, self.m_neighborFloorIdx[3]);
66  SwapEndianness(e, self.m_currentPropagationId);
67 }
68 
69 class NavRasterColumn
70 {
71  KY_CLASS_WITHOUT_COPY(NavRasterColumn);
72 public:
73  NavRasterColumn() {}
74 
75  BlobArray<NavRasterPixel> m_navRasterPoints;
76 };
77 inline void SwapEndianness(Endianness::Target e, NavRasterColumn& self)
78 {
79  SwapEndianness(e, self.m_navRasterPoints);
80 }
81 
82 
83 class NavRasterCell
84 {
85  KY_ROOT_BLOB_CLASS(Generator, NavRasterCell, 1)
86 public:
87  KyFloat32 m_rasterPrecision;
88  PixelAndCellGrid m_pixelAndCellGrid;
89  CellDesc m_cellDesc;
90  BlobArray<NavRasterColumn> m_columns; // row major
91 };
92 inline void SwapEndianness(Endianness::Target e, NavRasterCell& self)
93 {
94  SwapEndianness(e, self.m_rasterPrecision);
95  SwapEndianness(e, self.m_pixelAndCellGrid);
96  SwapEndianness(e, self.m_cellDesc);
97  SwapEndianness(e, self.m_columns);
98 }
99 
100 KY_INLINE NavRasterPixel::NavRasterPixel() :
101  m_altitude(0.f),
102  m_floorColor(PixelColor_Unset),
103  m_connexIdx(KyUInt32MAXVAL),
104  m_connectedComponentIdx(KyUInt32MAXVAL),
105  m_navTagIdx(KyUInt32MAXVAL),
106  m_featureBitField(0),
107  m_currentPropagationId(KyUInt32MAXVAL)
108 {
109  for(KyUInt32 i=0; i<4; ++i)
110  m_neighborFloorIdx[i] = NavRasterFloorIdx_Invalid;
111 }
112 
113 KY_INLINE KyUInt32 NavRasterPixel::GetNeighborFloorIndex(CardinalDir dir) const { return m_neighborFloorIdx[dir]; }
114 KY_INLINE KyUInt32 NavRasterPixel::GetFeatureMask(CardinalDir dir) const
115 {
116 /*
117  const KyUInt32 bitshift = dir*8;
118  return ((0xFF << bitshift) & m_featureBitField) >> bitshift;*/
119  switch (dir)
120  {
121  case 0:
122  {
123  const KyUInt32 bitshift = 0;
124  return ((0xFF << bitshift) & m_featureBitField) >> bitshift;
125  }
126  case 1:
127  {
128  const KyUInt32 bitshift = 8;
129  return ((0xFF << bitshift) & m_featureBitField) >> bitshift;
130  }
131  case 2:
132  {
133  const KyUInt32 bitshift = 16;
134  return ((0xFF << bitshift) & m_featureBitField) >> bitshift;
135  }
136  case 3:
137  {
138  const KyUInt32 bitshift = 24;
139  return ((0xFF << bitshift) & m_featureBitField) >> bitshift;
140  }
141  default:
142  return KyUInt32MAXVAL;
143  }
144 }
145 
146 }
147 
148 
149 #endif
150 
KyUInt32 CardinalDir
Defines a type that refers to one of the cardinal points on the compass:
Definition: cardinaldir.h:23
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43