gwnavruntime/database/databasegenmetrics.h Source File

databasegenmetrics.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 
15 
16 namespace Kaim
17 {
18 
23 {
24  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
26 public:
29 
30  // Clears all information maintained by this object. For internal use.
31  void Clear();
32  bool IsClear() const;
33 
34  // ------------------------------ Functions -----------------------------
35 
36  KyFloat32 GetCellSize() const;
40  KyFloat32 GetPixelSize() const;
41 
43  KyFloat32 GetFloatValueFromInteger64(KyInt64 inputValue) const;
44  KyFloat32 GetFloatValueFromInteger32(KyInt32 inputValue) const;
45 
46  CoordPos64 ComputeCellOrigin(const CellPos& cellPos) const;
47 
48  // ---------------------------------- Functions to compute CellPos ----------------------------------
49 
51  CellPos ComputeCellPos(const Vec2f& pos) const;
52 
56  void ComputeCellPos(const Vec2f& pos, CellPos& cellPos) const;
57 
59  CellPos ComputeCellPos(const Vec3f& pos) const;
60 
64  void ComputeCellPos(const Vec3f& pos, CellPos& cellPos) const;
65 
67  CellPos ComputeCellPosFromCoordPos64(const CoordPos64& coordPos64) const;
68 
72  void ComputeCellPosFromCoordPos64(const CoordPos64& coordPos64, CellPos& cellPos) const;
73 
74  // ---------------------------------- Conversion from floating-point coordinates to 64 bits integer coordinates ----------------------------------
75 
76  CoordPos64 GetCoordPos64FromVec3f(const Vec3f& inputPosition) const;
77  void GetCoordPos64FromVec3f(const Vec3f& inputPosition, CoordPos64& result) const;
78 
79  CoordPos64 GetCoordPos64FromVec2f(const Vec2f& inputPosition) const;
80  void GetCoordPos64FromVec2f(const Vec2f& inputPosition, CoordPos64& result) const;
81 
82  // ---------------------------------- Conversion from 64 bits integer coordinates to floating-point coordinates ----------------------------------
83 
84  Vec2f GetVec2fFromCoordPos64(const CoordPos64& inputPosition) const;
85  void GetVec2fFromCoordPos64(const CoordPos64& inputPosition, Vec2f& result) const;
86 
87  // ---------------------------------- Conversion from floating-point coordinates to WorldIntegerPos coordinates ----------------------------------
88 
89  WorldIntegerPos GetWorldIntegerPosFromVec2f(const Vec2f& inputPosition) const;
90  void GetWorldIntegerPosFromVec2f(const Vec2f& inputPosition, WorldIntegerPos& result) const;
91 
92  WorldIntegerPos GetWorldIntegerPosFromVec3f(const Vec3f& inputPosition) const;
93  void GetWorldIntegerPosFromVec3f(const Vec3f& inputPosition, WorldIntegerPos& result) const;
94 
95  // ---------------------------------- Conversion from WorldIntegerPos coordinates to floating-point coordinates ----------------------------------
96 
97  Vec2f GetVec2fFromWorldIntegerPos(const WorldIntegerPos& inputPosition) const;
98  void GetVec2fFromWorldIntegerPos(const WorldIntegerPos& inputPosition, Vec2f& result) const;
99 
100  // ---------------------------------- CoordPos64 <-> WorldIntegerPos Conversion ----------------------------------
101 
102  WorldIntegerPos GetWorldIntegerPosFromCoordPos64(const CoordPos64& inputPosition) const;
103  void GetWorldIntegerPosFromCoordPos64(const CoordPos64& inputPosition, WorldIntegerPos& result) const;
104 
105  CoordPos64 GetCoordPos64FromWorldIntegerPos(const WorldIntegerPos& inputPosition) const;
106  void GetCoordPos64FromWorldIntegerPos(const WorldIntegerPos& inputPosition, CoordPos64& result) const;
107 
108  // ---------------------------------- CellBox computation ----------------------------------
109 
110  void GetCellBoxOfAnAABBox(const Box2f& aABB , CellBox& cellBox) const;
111  void GetCellBoxOfAnAABBox(const Box3f& aABB , CellBox& cellBox) const;
112  void GetCellBoxOfAnAABBox(const CoordBox64& aABB, CellBox& cellBox) const;
113 
114 public: //internal
115  void SetDefaultValues();
116  KyFloat32 SnapFloatOnIntegerGrid(KyFloat32 inputValue) const;
117  KyInt32 SnapFloatOnPixelGrid(KyFloat32 inputValue) const;
118  KyInt64 ComputeCellPosXFromInteger64(KyInt64 x) const;
119  KyInt64 ComputeCellPosYFromInteger64(KyInt64 y) const;
120 
121 public: // internal
122 
125  void Setup();
126 
127 public: // internal
128 
129  // ---------------------------------- Members to be initialized before calling Setup() ----------------------------------
130 
136 
137  // ---------------------------------- Initialized from other members in Setup() ----------------------------------
138 
142 };
143 
144 }
145 
147 
148 
CellPos ComputeCellPos(const Vec2f &pos) const
Retrieves the position of theNavCell in the grid that is responsible for the specified (X...
Definition: databasegenmetrics.inl:55
CoordPos64 GetCoordPos64FromVec2f(const Vec2f &inputPosition) const
Retrieves the 64-bit integer coordinates that correspond to the specified floating-point coordinates...
Definition: databasegenmetrics.inl:130
2d axis aligned box of 32bits floating points
Definition: box2f.h:15
KyInt64 GetNearestInteger64FromFloatValue(KyFloat32 inputValue) const
Retrieves the 64-bit integer nearest to the specified float.
Definition: databasegenmetrics.inl:61
KyFloat32 m_pixelSize
For internal use. Do not modify. Value set in Setup() based on m_integerPrecision.
Definition: databasegenmetrics.h:140
KyFloat32 m_generationRadius
The radius of the character the NavMeshes in this DatabaseGenMetrics were generated for...
Definition: databasegenmetrics.h:131
KyFloat32 GetGenerationHeight() const
Retrieves the height of the character that the NavMeshes in this Database were generated for...
Definition: databasegenmetrics.inl:32
2d axis aligned box of 32bits integers. Very Important: CountX() returns m_max.x - m_min...
Definition: box2i.h:17
KyFloat32 GetCellSize() const
Retrieves the size (length and width) of theNavCells in this Database.
Definition: databasegenmetrics.inl:30
CoordPos64 GetCoordPos64FromVec3f(const Vec3f &inputPosition) const
Retrieves the 64-bit integer coordinates that correspond to the specified floating-point coordinates...
Definition: databasegenmetrics.inl:124
KyInt32 m_cellSizeInCoord
The number of integer steps in the length and width of each cell. Do not modify. Value set in Setup()...
Definition: databasegenmetrics.h:141
void GetCellBoxOfAnAABBox(const Box2f &aABB, CellBox &cellBox) const
Computes a CellBox from a Box2f.
Definition: databasegenmetrics.inl:173
WorldIntegerPos GetWorldIntegerPosFromVec3f(const Vec3f &inputPosition) const
Retrieves the WorldIntegerPos coordinates that correspond to the specified floating-point coordinates...
Definition: databasegenmetrics.inl:156
CellPos ComputeCellPosFromCoordPos64(const CoordPos64 &coordPos64) const
Retrieves the position of theNavCell in the grid that is responsible for the specified (X...
Definition: databasegenmetrics.inl:95
WorldIntegerPos GetWorldIntegerPosFromCoordPos64(const CoordPos64 &inputPosition) const
Retrieves the integer coordinates that correspond to the specified 64-bit integer coordinates...
Definition: databasegenmetrics.inl:137
void Setup()
Initialize m_integerPrecisionInv, m_pixelSize and m_cellSizeInCoord, it has to be called after other ...
Definition: databasegenmetrics.cpp:13
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
void Clear()
Clears all information maintained by this object. For internal use.
Definition: databasegenmetrics.inl:14
2d vector using KyInt64
Definition: vec2ll.h:18
Vec2f GetVec2fFromWorldIntegerPos(const WorldIntegerPos &inputPosition) const
Retrieves the floating-point coordinates that correspond to the specified WorldIntegerPos coordinates...
Definition: databasegenmetrics.inl:195
KyFloat32 m_altitudeTolerance
The maximum difference in altitude that may exist between the NavMesh and the original terrain mesh...
Definition: databasegenmetrics.h:133
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
void SetDefaultValues()
Clears all information maintained by this object. For internal use.
Definition: databasegenmetrics.inl:18
KyFloat32 GetFloatValueFromInteger64(KyInt64 inputValue) const
Retrieves the float nearest to the specified 64-bit integer.
Definition: databasegenmetrics.inl:67
3d axis aligned box of 32bits floating points
Definition: box3f.h:16
CoordPos64 GetCoordPos64FromWorldIntegerPos(const WorldIntegerPos &inputPosition) const
Retrieves the 64-bit integer coordinates that correspond to the specified WorldIntegerPos coordinates...
Definition: databasegenmetrics.inl:161
2d vector using KyFloat32.
Definition: vec2f.h:18
std::int64_t KyInt64
int64_t
Definition: types.h:25
KyFloat32 GetGenerationRadius() const
Retrieves the radius of the character that NavMeshes in this Database were generated for...
Definition: databasegenmetrics.inl:31
2d vector using KyInt32
Definition: vec2i.h:18
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Vec2f GetVec2fFromCoordPos64(const CoordPos64 &inputPosition) const
Retrieves the floating-point coordinates that correspond to the specified 64-bit integer coordinates...
Definition: databasegenmetrics.inl:183
KyFloat32 m_integerPrecision
For internal use. Do not modify.
Definition: databasegenmetrics.h:134
CoordPos64 ComputeCellOrigin(const CellPos &cellPos) const
Retrieves the 64-bit integer coordinates that mark the origin point of theNavCell at the specified po...
Definition: databasegenmetrics.inl:111
WorldIntegerPos GetWorldIntegerPosFromVec2f(const Vec2f &inputPosition) const
Retrieves the WorldIntegerPos coordinates that correspond to the specified floating-point coordinates...
Definition: databasegenmetrics.inl:149
std::int32_t KyInt32
int32_t
Definition: types.h:24
Utilities for dealing with NavData coordinates, which are expressed in a world space based on integer...
Definition: worldintegerpos.h:19
KyFloat32 GetFloatValueFromInteger32(KyInt32 inputValue) const
Retrieves the float nearest to the specified 32-bit integer.
Definition: databasegenmetrics.inl:73
KyFloat32 GetGenerationAltitudeTolerance() const
Retrieves the altitude tolerance parameters that the NavMeshes in this Database were generated with...
Definition: databasegenmetrics.inl:33
KyFloat32 m_integerPrecisionInv
For internal use. Do not modify. Value set in Setup() based on m_integerPrecision.
Definition: databasegenmetrics.h:139
KyFloat32 GetPixelSize() const
Retrieves the size of pixel (raster precision) that the NavMeshes in this Database were generated wit...
Definition: databasegenmetrics.inl:34
KyFloat32 m_generationHeight
The height of the character the NavMeshes in this DatabaseGenMetrics were generated for...
Definition: databasegenmetrics.h:132
This class gathers a set of generation parameters of one Database and manages the conversion between ...
Definition: databasegenmetrics.h:22
2d axis aligned box of 64bits integers. Does not maintain m_countXY = m_max - m_min as a member...
Definition: box2ll.h:16
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16
KyInt32 m_cellSizeInPixel
The number of raster pixels in the length and width of each cell. Do not modify.
Definition: databasegenmetrics.h:135