9 #ifndef GwNavGen_NavRasterCellScanlinePainter_H
10 #define GwNavGen_NavRasterCellScanlinePainter_H
23 class DynamicNavRasterCell;
25 class NavRasterWorkingPixel;
26 class DynamicNavRasterFinalColumn;
28 class NavRasterCellScanlinePainter
31 enum SearchResult { SEARCH_RESULT_FOUND, NO_SEARCH_RESULT };
36 ScanPixel(NavRasterPixel* columnElement,
const PixelPos& pos,
KyUInt32 floor) :
37 m_navPixel(columnElement), m_pos(pos), m_floorIdx(floor) {}
39 NavRasterPixel* m_navPixel;
49 ScanPixel m_fisrtBoundaryPixel;
50 ScanPixel m_lastBoundaryPixel;
58 m_color(color), m_pixelCount(0), m_connectedComponentIdx(connectedComponentIdx),
59 m_boundaryPixelBorderCount(0) , m_indexInBinaryHeap(BinaryHeapInvalidReference) {}
60 void UpdateColorDataFromNewPixel(NavRasterPixel* pixel,
const PixelPos& pos);
68 FloorAltitudeRange m_altRange;
73 NavRasterCellScanlinePainter() : m_navRaster(
KY_NULL), m_paintingMs(
KY_NULL) {}
78 void SetNavRasterCell(DynamicNavRasterCell* cell) { m_navRaster = cell; }
79 void SetConnexIdxToNavTagIdxArray(KyArrayTLS_POD<KyUInt32>* connexIdxToNavTagIdxArray) { m_connexIdxToNavTagIdxArray = connexIdxToNavTagIdxArray ;}
80 void SetPaintingMs(
KyFloat32* paintingMs) { m_paintingMs = paintingMs; }
82 KyUInt32 GetNbColorsUsed()
const {
return m_colorCount; }
88 void RemoveSmallNavTagArea();
91 void ComputeConnectedComponent();
94 void ComputeColorsByPropagation();
103 void PropagateInSouthWestBox();
104 void PropagateInSouthEastBox();
105 void PropagateInNorthWestBox();
106 void PropagateInNorthEastBox();
108 void PropagateFromCornerColumn(
const PixelBox& paintBox,
const PixelPos& cornerPos,
CardinalDir expandLineDir,
CardinalDir lineMoveDir);
109 void PropagateFromCornerPixel(
const PixelBox& paintBox,
const ScanPixel& seedPixel,
CardinalDir expandLineDir,
CardinalDir lineMoveDir);
110 PixelBox ComputeLocalPaintBoxForCorner(
const PixelBox& paintBox,
const ScanPixel& corner,
CardinalDir expandLineDir,
CardinalDir lineMoveDir);
112 void PropagateFromBoxBorder(
const PixelBox& paintBox,
const PixelPos& startPos,
CardinalDir expandLineDir,
CardinalDir lineMoveDir);
113 void PropagateFromBorderPixel(
const PixelBox& paintBox,
const ScanPixel& seedPixel,
CardinalDir expandLineDir,
CardinalDir lineMoveDir);
114 PixelBox ComputeLocalPaintBoxForBorder(
const PixelBox& paintBox,
const ScanPixel& seedPixel,
CardinalDir expandLineDir,
CardinalDir lineMoveDir);
116 void DisconnectOutsidePixelsAtBoxBounds(
const PixelBox& paintBox,
const ScanPixel& corner,
CardinalDir dirAlongBorder,
119 void PropagateFromAllRemainingUncoloredPixels();
120 void PropagateFromUncoloredNonBorderPixel(
const ScanPixel& startPixel);
122 void ColorCellBoundaryPixelLineInBox(
const PixelBox& localPaintBox,
const ScanPixel& startPixel, PixelColor color,
125 bool TwoNeighborPixelHaveSameColor(
const ScanPixel& pixel1,
const ScanPixel& pixel2,
CardinalDir dir, PixelColor currentColor);
126 bool CanPropagateToPixel(PixelPos& pixelPos,
KyUInt32 currentFloorIdx,
KyUInt32 propagationIdx);
128 void FindLowerConnectedPixel(
const ScanPixel& startPixel, ScanPixel& lowerPixel);
129 void CastPixelUntillBoundary(
const ScanPixel& startScanPixel,
CardinalDir castDir);
131 PixelPos CastCellBoundaryPixel(
const PixelBox& bbox,
const ScanPixel& borderPixel,
CardinalDir castDir,
CardinalDir borderDir);
132 void CastPixelCheckingColor(
const ScanPixel& scanLine, PixelColor color,
const PixelBox& bbox,
CardinalDir castdir);
133 void PaintLastPixelCastResultAndOutsideNeighbors(PixelColor color,
CardinalDir borderDir);
135 bool IsConnectedInDir(
const ScanPixel& pixel,
CardinalDir dir, ScanPixel& result);
136 void GetNeighborScanPixel(
const ScanPixel& borderPixel,
CardinalDir neighborDir, ScanPixel& neighborPixel);
137 void GetNeighborScanPixel(
const PixelBox& bbox,
const ScanPixel& borderPixel,
CardinalDir neighborDir, ScanPixel& neighborPixel);
139 PixelColor GetNewColor(
KyUInt32 connectedComponentIdx);
140 void ColorPixel(
const ScanPixel& pixel, PixelColor color);
142 bool CanSetColorToPixel(PixelPos& pixelPos,
KyUInt32 floor, PixelColor newColor);
143 bool IsColorPresentInOtherFloorOfColumn(
const DynamicNavRasterFinalColumn& column,
KyUInt32 ignoredFloorIdx, PixelColor newColor);
144 bool IsColorPresentInOtherFloorOfColumn(
const DynamicNavRasterFinalColumn& column,
KyUInt32 ignoredFloorIdx1,
KyUInt32 ignoredFloorIdx2, PixelColor newColor);
146 bool CanPaintNeighborLine(
const ScanPixel& startScanPixel,
const ScanPixel& endScanPixel, PixelColor color,
const PixelBox& bbox,
147 CardinalDir lineDir,
CardinalDir expandDir, ScanPixel& borderLineStartScanPixel, ScanPixel& borderLineEndScanPixel,
151 void DetectForbiddenColorMergeAndConnectedColors();
152 void ComputeMergedColors();
153 void ApplyFinalColorToPixels();
155 class ScanPixelSorterByAlt
158 bool operator() (
const ScanPixel& pixel1,
const ScanPixel& pixel2)
const
160 return pixel1.m_navPixel->m_altitude < pixel2.m_navPixel->m_altitude;
164 void TagNavTagConnectedComponent(
const PixelBox& safenavTagRemovalBox,
const ScanPixel& startPixel,
KyUInt32 connectedComponentIdx,
KyUInt32 minPixelCount);
165 void TagConnectedComponent(
const ScanPixel& startPixel,
KyUInt32 connectedComponentIdx);
166 void TagConnexConnectedComponentInFloor(
const ScanPixel& startPixel,
KyUInt32 currentConnexIdx);
168 DynamicNavRasterCell* m_navRaster;
171 KyArrayTLS<ScanPixel> m_popagationStatck;
172 KyArrayTLS_POD<ScanPixel> m_navTagArea;
173 KyArrayTLS_POD<ScanPixel> m_navTagAreaNeighbors;
174 KyArrayTLS<ColorData> m_colorData;
176 BitFieldTLS m_forbiddenColorMerge;
177 BitFieldTLS m_connectedColors;
178 KyArrayTLS_POD<PixelColor> m_finalColor;
180 KyArrayTLS<ScanPixel> m_castForwardResult;
181 KyArrayTLS<ScanPixel> m_castBackwardResult;
182 KyArrayTLS<ScanPixel> m_onePixelPerFinalColor;
184 BinaryHeapTls<ScanPixel, ScanPixelSorterByAlt> m_orderedPixels;
185 KyArrayTLS_POD<KyUInt32>* m_connexIdxToNavTagIdxArray;
193 KY_INLINE
bool NavRasterCellScanlinePainter::IsConnectedInDir(
const ScanPixel& pixel,
CardinalDir dir, ScanPixel& result)
195 GetNeighborScanPixel(pixel, dir, result);
196 return result.m_navPixel !=
KY_NULL;
199 KY_INLINE PixelColor NavRasterCellScanlinePainter::GetNewColor(
KyUInt32 connectedComponentIdx)
201 PixelColor color = m_colorData.GetCount();
202 m_colorData.PushBack(ColorData(color, connectedComponentIdx));
205 KY_INLINE
void NavRasterCellScanlinePainter::ColorPixel(
const ScanPixel& pixel, PixelColor color)
207 KY_ASSERT(pixel.m_navPixel !=
KY_NULL);
208 KY_ASSERT(pixel.m_navPixel->m_floorColor == PixelColor_Unset);
209 KY_ASSERT(color < m_colorData.GetCount());
211 pixel.m_navPixel->m_floorColor = color;
212 m_colorData[color].UpdateColorDataFromNewPixel(pixel.m_navPixel, pixel.m_pos);
214 KY_INLINE
void NavRasterCellScanlinePainter::ColorData::UpdateColorDataFromNewPixel(NavRasterPixel* currentPixel,
const PixelPos& pos)
216 KY_LOG_ERROR_IF(currentPixel->m_floorColor != m_color, (
"Wrong color data for this pixel"));
218 m_altRange.Update(currentPixel->m_altitude);
219 m_box.ExpandByVec2(pos);
222 if (currentPixel->m_neighborFloorIdx[i] == NavRasterFloorIdx_Invalid)
223 ++m_boundaryPixelBorderCount;
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
#define KY_NULL
Null value.
Definition: types.h:247
KyUInt32 CardinalDir
Defines a type that refers to one of the cardinal points on the compass:
Definition: cardinaldir.h:23
#define KyInt32MAXVAL
The maximum value that can be stored in the KyInt32 variable type.
Definition: types.h:224
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