gwnavgeneration/navmesh/dynamicnavfloorheightfield.h Source File

dynamicnavfloorheightfield.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 
13 
14 namespace Kaim
15 {
16 
17 class GeneratorSystem;
18 class DynamicRasterCell;
19 
20 enum NavFloorHeightFieldErrorUpdateStatus
21 {
22  NavFloorHeightFieldErrorStatus_Updated,
23  NavFloorHeightFieldErrorStatus_NoProjections
24 };
25 
26 enum NavFloorHeightFieldPointStatus
27 {
28  NavFloorHeightFieldPointStatus_Valid,
29  NavFloorHeightFieldPointStatus_Disabled
30 };
31 
32 typedef Vec2i HeighfieldQuadPos;
33 typedef Box2i HeighfieldQuadBox;
34 
35 class NavFloorHeightFieldPoint
36 {
37  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
38 public:
39  NavFloorHeightFieldPoint()
40  : m_pos(0.0f,0.0f),
41  m_minLocalAlt(KyFloat32MAXVAL),
42  m_maxLocalAlt(-KyFloat32MAXVAL),
43  m_error(0.0f),
44  m_status(NavFloorHeightFieldPointStatus_Valid) {}
45 
46  NavFloorHeightFieldPoint(const Vec2f& pos, KyFloat32 alt)
47  : m_pos(pos),
48  m_minLocalAlt(alt),
49  m_maxLocalAlt(alt),
50  m_error(0.0f),
51  m_status(NavFloorHeightFieldPointStatus_Valid) {}
52 
53 public:
54  Vec2f m_pos;
55  KyFloat32 m_minLocalAlt;
56  KyFloat32 m_maxLocalAlt;
57  KyFloat32 m_error;
58  NavFloorHeightFieldPointStatus m_status;
59 };
60 
61 // 1 HeighfieldQuad can be 1x1 pixel, 2x2 pixels, 3x3 pixels ...
62 // <---QUAD--> <---QUAD-->
63 // ^ +-----+-----+-----+-----+
64 // Q | pix | pix | pix | pix |
65 // U | el | el | el | el |
66 // A +-----+-----+-----+-----+
67 // D | pix | pix | pix | pix |
68 // v | el | el | el | el |
69 // +-----+-----+-----+-----+
70 
71 class NavFloorHeightField
72 {
73  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
74 public:
75  NavFloorHeightField(GeneratorSystem* sys, const PixelBox& navPixelBox);
76 
77  void AddPoint(const PixelPos& pixelPos, KyFloat32 alt);
78  NavFloorHeightFieldErrorUpdateStatus UpdateErrors(const DynamicRasterCell* rasterCell);
79  NavFloorHeightFieldPoint* GetWorstErrorPoint();
80  NavFloorHeightFieldPoint* GetPointAtLocalHeightFieldPos(const HeighfieldQuadPos& heighfieldPixelPos);
81  NavFloorHeightFieldPoint* GetPointAtAbsoluteHeightFieldPos(const HeighfieldQuadPos& heighfieldPixelPos);
82  KyFloat32 ComputeQuadSizeInMeters() const;
83 
84 public:
85  GeneratorSystem* m_sys;
86  PixelBox m_navPixelBox; // from the raster (exclusive + 1 pixel overlap)
87  Coord m_pixelSize; // integer coordinates
88  KyInt32 m_quadSizeInPixel; // typically 1 to 3
89  Coord m_quadSize; // integer coordinates
90  HeighfieldQuadBox m_heightFieldQuadBox; // in quads
91  HeighfieldQuadBox m_heightFieldBoundingQuadBox; // updated when adding new point
92  KyArrayTLS<NavFloorHeightFieldPoint> m_points;
93  KyArrayTLS_POD<KyUInt32> m_grid; // [RowMajorIndex in m_heightFieldQuadBox] of point index
94 };
95 
96 }
97 
#define KyFloat32MAXVAL
KyFloat32 max value
Definition: types.h:71
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
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
std::int32_t KyInt32
int32_t
Definition: types.h:24
float KyFloat32
float
Definition: types.h:32