gwnavruntime/navmesh/blobs/flooraltituderange.h Source File

flooraltituderange.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 
10 
11 namespace Kaim
12 {
13 
16 {
17  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
18 public:
19  FloorAltitudeRange() { Clear(); }
20 
21  void Clear()
22  {
25  }
26 
31  bool IsAltitudeInside(KyFloat32 altitude, KyFloat32 toleranceAboveFloor, KyFloat32 toleranceBelowFloor) const;
32 
34  bool DoesIntersect(const FloorAltitudeRange& other) const;
35 
37  bool DoesIntersect(KyFloat32 zmin, KyFloat32 zmax) const;
38 
39  void Update(KyFloat32 altitude);
40 
41  KyFloat32 GetAltDiff() const { return m_maxZ - m_minZ; }
42 public:
45 };
46 
47 KY_INLINE void SwapEndianness(Endianness::Target e, FloorAltitudeRange& self)
48 {
49  SwapEndianness(e, self.m_minZ);
50  SwapEndianness(e, self.m_maxZ);
51 }
52 
53 
54 KY_INLINE bool FloorAltitudeRange::IsAltitudeInside(KyFloat32 altitude, KyFloat32 toleranceAboveFloor, KyFloat32 toleranceBelowFloor) const
55 {
56  const KyFloat32 operand1 = Fsel(altitude - (m_minZ - toleranceBelowFloor), 1.f, 0.f); // (operand1 == 1.f) <=> (altitude >= m_minZ - toleranceBelowFloor)
57  const KyFloat32 operand2 = Fsel((m_maxZ + toleranceAboveFloor) - altitude, 1.f, 0.f); // (operand2 == 1.f) <=> (m_maxZ + toleranceAboveFloor >= altitude)
58 
59  return operand1 * operand2 > 0.f;
60 }
61 
62 KY_INLINE bool FloorAltitudeRange::DoesIntersect(const FloorAltitudeRange& other) const
63 {
64  return DoesIntersect(other.m_minZ, other.m_maxZ);
65 }
66 
67 KY_INLINE bool FloorAltitudeRange::DoesIntersect(KyFloat32 zmin, KyFloat32 zmax) const
68 {
69  const KyFloat32 operand1 = Fsel(zmax - m_minZ, 1.f, 0.f); // (operand1 == 1.f) <=> (other.m_maxZ >= m_minZ)
70  const KyFloat32 operand2 = Fsel(m_maxZ - zmin, 1.f, 0.f); // (operand2 == 1.f) <=> (m_maxZ >= other.m_minZ)
71 
72  return operand1 * operand2 > 0.f;
73 }
74 
75 KY_INLINE void FloorAltitudeRange::Update(KyFloat32 altitude)
76 {
77  m_minZ = Kaim::Min(m_minZ, altitude);
78  m_maxZ = Kaim::Max(m_maxZ, altitude);
79 }
80 
81 }
82 
83 
84 
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:62
Represents the range of altitudes covered by a single NavFloorBlob.
Definition: flooraltituderange.h:15
KyFloat32 m_minZ
Stores the minimum altitude covered by this range. Do not modify.
Definition: flooraltituderange.h:43
#define KyFloat32MAXVAL
KyFloat32 max value
Definition: types.h:71
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
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:54
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
KyFloat32 m_maxZ
Stores the maximum altitude covered by this range. Do not modify.
Definition: flooraltituderange.h:44
KyFloat32 Fsel(KyFloat32 a, KyFloat32 x, KyFloat32 y)
x if a>=0.0f, y if a<0.0f>
Definition: fastmath.h:19
float KyFloat32
float
Definition: types.h:32