gwnavruntime/pathfollower/circlearcsplineturn.h Source File

circlearcsplineturn.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 
9 
13 
14 
15 //#define CircleArcSplineBubbleData_MaintainGateAndRadiusRange
16 
17 
18 namespace Kaim
19 {
20 
21 class CircleArcSplineComputer;
22 class CircleArcSplineTurn;
23 class Channel;
24 
25 
26 // Internal: Class used to enrich Bubbles with some data useful for
27 // CircleArcSpline computation.
28 class CircleArcSplineBubbleData
29 {
30 public:
31  CircleArcSplineBubbleData() { Reset(); }
32 
33  BubbleType GetBubbleType() const { return m_bubbleType; }
34 
35 #ifdef CircleArcSplineBubbleData_MaintainGateAndRadiusRange
36  KyUInt32 GetFirstGateIndex() const { return m_firstGateIndex; }
37  KyUInt32 GetLastGateIndex() const { return m_lastGateIndex; }
38  KyFloat32 GetMinRadius() const { return m_minRadius; }
39  KyFloat32 GetMaxRadius() const { return m_maxRadius; }
40 #endif // CircleArcSplineBubbleData_MaintainGateAndRadiusRange
41 
42  const Vec3f& GetMidPoint() const { return m_midPoint; }
43  const Vec2f& GetMedianTurnAxis() const { return m_medianTurnAxis; }
44  const Vec3f& GetEntryPos() const { return m_entryPos; }
45  const Vec3f& GetExitPos() const { return m_exitPos; }
46  KyUInt32 GetEntrySectionIdx() const { return m_entrySectionIdx; }
47  KyUInt32 GetExitSectionIdx() const { return m_exitSectionIdx; }
48  const Vec2f& GetEntryDir() const { return m_entryDir; }
49  const Vec2f& GetExitDir() const { return m_exitDir; }
50  KyUInt32 GetRadiusIndexInProfile() const { return m_radiusIndexInProfile; }
51  bool HasRangeBeenDefined() const { return m_hasRangeBeenDefined; }
52 
53  void Reset()
54  {
55  m_bubbleType = UndefinedBubbleType;
56  m_radiusIndexInProfile = KyUInt32MAXVAL;
57 
58 #ifdef CircleArcSplineBubbleData_MaintainGateAndRadiusRange
59  m_firstGateIndex = KyUInt32MAXVAL;
60  m_lastGateIndex = KyUInt32MAXVAL;
61  m_minRadius = KyFloat32MAXVAL;
62  m_maxRadius = 0.0f;
63 #endif // CircleArcSplineBubbleData_MaintainGateAndRadiusRange
64 
65  m_hasRangeBeenDefined = false;
66  m_entrySectionIdx = KyUInt32MAXVAL;
67  m_exitSectionIdx = KyUInt32MAXVAL;
68  }
69 
70 private:
71  friend class CircleArcSplineTurn;
72  BubbleType m_bubbleType;
73  KyUInt32 m_radiusIndexInProfile;
74 
75 #ifdef CircleArcSplineBubbleData_MaintainGateAndRadiusRange
76  // Both are inclusive. Used to update min and max radius values.
77  KyUInt32 m_firstGateIndex;
78  KyUInt32 m_lastGateIndex;
79 
80  // The range of radius of the Bubbles with same center that do not cross any
81  // channel borders within the firstGate/lastGate range.
82  KyFloat32 m_minRadius;
83  KyFloat32 m_maxRadius;
84 #endif // CircleArcSplineBubbleData_MaintainGateAndRadiusRange
85 
86  bool m_hasRangeBeenDefined;
87  Vec2f m_medianTurnAxis; // The axis bisecting incoming border and outgoing border
88  Vec3f m_midPoint; // The point at MedianTurnAxis and Bubble circle intersection. We try to keep this position on the Bubble when optimizing the spline.
89 
90  Vec3f m_entryPos;
91  KyUInt32 m_entrySectionIdx;
92  Vec2f m_entryDir;
93 
94  Vec3f m_exitPos;
95  KyUInt32 m_exitSectionIdx;
96  Vec2f m_exitDir;
97 };
98 
99 
100 
101 // Internal: Class aggregating all useful information about a turn when building
102 // a CircleArcSpline.
103 class CircleArcSplineTurn
104 {
105 public:
106  CircleArcSplineTurn() : m_channel(nullptr) {}
107  CircleArcSplineTurn(const Channel* channel) : m_channel(channel) {}
108  CircleArcSplineTurn(const CircleArcSplineTurn& other) { *this = other; }
109 
110  void operator=(const CircleArcSplineTurn& other)
111  {
112  m_channel = other.m_channel;
113  m_bubble = other.m_bubble;
114  m_bubbleData = other.m_bubbleData;
115  }
116 
117  void Reset();
118 
119  const Bubble& GetBubble() const { return m_bubble; }
120  const CircleArcSplineBubbleData& GetBubbleData() const { return m_bubbleData; }
121 
122  void SetBubble(const Bubble& bubble, BubbleType bubbleType);
123 
124  void SetRadiusIndexInProfile(KyUInt32 radiusIndexInProfile) { m_bubbleData.m_radiusIndexInProfile = radiusIndexInProfile; }
125  void UpdateDataAsSinglePoint(const Vec3f& position, KyUInt32 sectionIdx);
126  void UpdateDataAsSinglePoint(const Vec3f& position, KyUInt32 sectionIdx, const Vec2f& entryDir, const Vec2f& exitDir);
127  void UpdateData(const Vec3f& entryPos, KyUInt32 entrySectionIdx, const Vec3f& exitPos, KyUInt32 exitSectionIdx);
128  void UpdateData(const Vec3f& entryPos, KyUInt32 entrySectionIdx, const Vec3f& exitPos, KyUInt32 exitSectionIdx, const Vec2f& entryDir, const Vec2f& exitDir);
129 
130 #ifdef CircleArcSplineBubbleData_MaintainGateAndRadiusRange
131  KyFloat32 GetMinDistLeft() const;
132  KyFloat32 GetMinDistRight() const;
133 #endif // CircleArcSplineBubbleData_MaintainGateAndRadiusRange
134 
135  bool IsASmallTurn(KyFloat32 fullTurnToleranceSin) const;
136 
137 private:
138  void ComputeMedianTurnAxis();
139 #ifdef CircleArcSplineBubbleData_MaintainGateAndRadiusRange
140  void ComputeRadiusRange();
141 #endif // CircleArcSplineBubbleData_MaintainGateAndRadiusRange
142 
143 private:
144  friend class CircleArcSplineComputer;
145  const Channel* m_channel;
146  Bubble m_bubble;
147  CircleArcSplineBubbleData m_bubbleData;
148 };
149 
150 
151 typedef SharedPoolList<CircleArcSplineTurn> TurnList;
152 
153 
154 } // namespace Kaim
155 
#define KyFloat32MAXVAL
KyFloat32 max value
Definition: types.h:71
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
BubbleType
Defines the type of a bubble accordingly to the place it has in a BubbleArray, a BubbleList, etc.
Definition: bubble.h:22
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
#define KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68
float KyFloat32
float
Definition: types.h:32