gwnavruntime/navmesh/blobs/flooraltituderange.h Source File

flooraltituderange.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: JUBA - secondary contact: NOBODY
9 #ifndef Navigation_FloorAltitudeRange_H
10 #define Navigation_FloorAltitudeRange_H
11 
13 
14 namespace Kaim
15 {
16 
19 {
20  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
21 public:
22  FloorAltitudeRange() { Clear(); }
23 
24  void Clear()
25  {
28  }
29 
34  bool IsAltitudeInside(KyFloat32 altitude, KyFloat32 toleranceAboveFloor, KyFloat32 toleranceBelowFloor) const;
35 
37  bool DoesIntersect(const FloorAltitudeRange& other) const;
38 
40  bool DoesIntersect(KyFloat32 zmin, KyFloat32 zmax) const;
41 
42  void Update(KyFloat32 altitude);
43 
44  KyFloat32 GetAltDiff() const { return m_maxZ - m_minZ; }
45 public:
48 };
49 
52 KY_INLINE void SwapEndianness(Endianness::Target e, FloorAltitudeRange& self)
53 {
54  SwapEndianness(e, self.m_minZ);
55  SwapEndianness(e, self.m_maxZ);
56 }
57 
58 
59 KY_INLINE bool FloorAltitudeRange::IsAltitudeInside(KyFloat32 altitude, KyFloat32 toleranceAboveFloor, KyFloat32 toleranceBelowFloor) const
60 {
61  const KyFloat32 operand1 = Fsel(altitude - (m_minZ - toleranceBelowFloor), 1.f, 0.f); // (operand1 == 1.f) <=> (altitude >= m_minZ - toleranceBelowFloor)
62  const KyFloat32 operand2 = Fsel((m_maxZ + toleranceAboveFloor) - altitude, 1.f, 0.f); // (operand2 == 1.f) <=> (m_maxZ + toleranceAboveFloor >= altitude)
63 
64  return operand1 * operand2 > 0.f;
65 }
66 
67 KY_INLINE bool FloorAltitudeRange::DoesIntersect(const FloorAltitudeRange& other) const
68 {
69  return DoesIntersect(other.m_minZ, other.m_maxZ);
70 }
71 
72 KY_INLINE bool FloorAltitudeRange::DoesIntersect(KyFloat32 zmin, KyFloat32 zmax) const
73 {
74  const KyFloat32 operand1 = Fsel(zmax - m_minZ, 1.f, 0.f); // (operand1 == 1.f) <=> (other.m_maxZ >= m_minZ)
75  const KyFloat32 operand2 = Fsel(m_maxZ - zmin, 1.f, 0.f); // (operand2 == 1.f) <=> (m_maxZ >= other.m_minZ)
76 
77  return operand1 * operand2 > 0.f;
78 }
79 
80 KY_INLINE void FloorAltitudeRange::Update(KyFloat32 altitude)
81 {
82  m_minZ = Kaim::Min(m_minZ, altitude);
83  m_maxZ = Kaim::Max(m_maxZ, altitude);
84 }
85 
86 }
87 
88 
89 #endif //Navigation_FloorAltitudeRange_H
90 
bool DoesIntersect(const FloorAltitudeRange &other) const
Returns true if the range of altitudes represented by this object intersects the range represented by...
Definition: flooraltituderange.h:69
Represents the range of altitudes covered by a single NavFloorBlob.
Definition: flooraltituderange.h:18
KyFloat32 m_minZ
Stores the minimum altitude covered by this range. Do not modify.
Definition: flooraltituderange.h:48
#define KyFloat32MAXVAL
The maximum value that can be stored in the KyFloat32 variable type.
Definition: types.h:227
T Min(const T &a, const T &b)
Returns the lesser of the two specified values.
Definition: fastmath.h:113
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
bool IsAltitudeInside(KyFloat32 altitude, KyFloat32 toleranceAboveFloor, KyFloat32 toleranceBelowFloor) const
Returns true if the specified coordinates are within the range of altitudes represented by this objec...
Definition: flooraltituderange.h:61
T Max(const T &a, const T &b)
Returns the greater of the two specified values.
Definition: fastmath.h:121
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
KyFloat32 m_maxZ
Stores the maximum altitude covered by this range. Do not modify.
Definition: flooraltituderange.h:49
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
KyFloat32 Fsel(KyFloat32 cmp, KyFloat32 v1, KyFloat32 v2)
Ifcmp is greater than 0, returnsv1. Otherwise, returnsv2.
Definition: fastmath.h:58