gwnavgeneration/navmesh/dynamicnavfloorheightfield.h Source File

dynamicnavfloorheightfield.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: NONE
9 #ifndef GwNavGen_DynamicNavFloorHeightField_H
10 #define GwNavGen_DynamicNavFloorHeightField_H
11 
12 
17 
18 namespace Kaim
19 {
20 
21 class GeneratorSystem;
22 class DynamicRasterCell;
23 
24 
25 enum NavFloorHeightFieldErrorUpdateStatus
26 {
27  NavFloorHeightFieldErrorStatus_Updated,
28  NavFloorHeightFieldErrorStatus_NoProjections
29 };
30 
31 enum NavFloorHeightFieldPointStatus
32 {
33  NavFloorHeightFieldPointStatus_Valid,
34  NavFloorHeightFieldPointStatus_Disabled
35 };
36 
37 struct NavFloorHeightFieldPoint
38 {
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& position2D, KyFloat32 alt)
47  : m_pos(position2D),
48  m_minLocalAlt(alt),
49  m_maxLocalAlt(alt),
50  m_error(0.0f),
51  m_status(NavFloorHeightFieldPointStatus_Valid){}
52 
53  bool operator == (const NavFloorHeightFieldPoint& other)
54  {
55  // for pos & alts are enough
56  bool same = other.m_pos == m_pos
57  && other.m_maxLocalAlt == m_maxLocalAlt
58  && other.m_minLocalAlt == m_minLocalAlt;
59 
60  return same;
61  }
62 
63  Vec2f m_pos;
64  KyFloat32 m_minLocalAlt;
65  KyFloat32 m_maxLocalAlt;
66 
67  KyFloat32 m_error;
68  NavFloorHeightFieldPointStatus m_status;
69 };
70 
71 // --------------------------------------
72 // ----- DynamicNavFloorHeightField -----
73 // --------------------------------------
74 class DynamicNavFloorHeightField
75 {
76  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
77 public:
78  DynamicNavFloorHeightField(GeneratorSystem* sys, KyInt32 originalPixelSize, KyInt32 stride, const PixelBox& navPixelBox);
79 
80  void AddPoint(const PixelPos& coord, KyFloat32 alt);
81  NavFloorHeightFieldErrorUpdateStatus UpdateErrors(const DynamicRasterCell* rasterCell);
82  NavFloorHeightFieldPoint* GetWorstErrorPoint();
83  NavFloorHeightFieldPoint* GetPointAtLocalHeightFieldPos(const PixelPos& pos);
84  NavFloorHeightFieldPoint* GetPointAtAbsoluteHeightFieldPos(const PixelPos& pos);
85 
86 public:
87  GeneratorSystem* m_sys;
88  KyInt32 m_originalPixelSize; // must be >0
89  KyInt32 m_stride; // must be >0
90  PixelBox m_navPixelBox; // from the raster (exclusive + 1 pixel overlap)
91  PixelBox m_heightFieldPixelBox; // same but with pixelSize = m_stride * m_sys->Partition().m_pixelSize
92  PixelBox m_heightFieldBoundingPixelBox; // updated when adding new point
93  KyArrayTLS<NavFloorHeightFieldPoint> m_points;
94  KyArrayTLS_POD<KyUInt32> m_grid;
95 };
96 
97 }
98 
99 
100 #endif //GwNavGen_DynamicNavFloor_H
101 
#define KyFloat32MAXVAL
The maximum value that can be stored in the KyFloat32 variable type.
Definition: types.h:227
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43