7 #ifndef Navigation_BubbleToCornerFunnel_H
8 #define Navigation_BubbleToCornerFunnel_H
19 class BubbleToCornerFunnel;
20 class ScopedDisplayList;
23 class BubbleFunnelBorder
27 : m_isInitialized(false)
30 BubbleFunnelBorder(
KyUInt32 bubbleIdx,
const Vec3f& segmentStart,
const Vec3f& segmentEnd)
32 Set(bubbleIdx, segmentStart, segmentEnd);
37 m_isInitialized =
false;
40 void Set(
KyUInt32 bubbleIdx,
const Vec3f& segmentStart,
const Vec3f& segmentEnd)
42 m_segmentStart = segmentStart;
43 m_segmentEnd = segmentEnd;
45 const Vec2f segmentVec2d = segmentEnd.Get2d() - segmentStart.Get2d();
46 m_segmentLength2d = segmentVec2d.GetNormalized(m_segmentDir2d);
48 m_bubbleIdx = bubbleIdx;
49 m_isInitialized =
true;
52 const Vec3f& GetSegmentStart()
const {
return m_segmentStart; }
53 const Vec3f& GetSegmentEnd()
const {
return m_segmentEnd; }
54 const Vec2f& GetSegmentDir2d()
const {
return m_segmentDir2d; }
55 KyFloat32 GetSegmentLength2d()
const {
return m_segmentLength2d; }
56 KyUInt32 GetBubbleIdx()
const {
return m_bubbleIdx; }
57 bool IsInitialized()
const {
return m_isInitialized; }
60 friend class BubbleToCornerFunnel;
72 class BubbleToCornerFunnel
76 : m_bubbleArray(bubbleArray)
77 , m_previousResult(FunnelUnchanged)
78 , m_leftBorderDisplayList(
KY_NULL)
79 , m_rightBorderDisplayList(
KY_NULL)
85 KyUInt32 GetApexIdx()
const {
return m_apexIdx; }
86 const Bubble& GetApexBubble()
const {
return m_apexBubble; }
87 const BubbleFunnelBorder& GetLeftBorder()
const {
return m_leftBorder; }
88 const BubbleFunnelBorder& GetRightBorder()
const {
return m_rightBorder; }
89 FunnelResult GetPreviousResult()
const {
return m_previousResult; }
92 bool IsStrictlyInTurnRange(
const Vec2f& entryDir,
const Vec2f& exitDir,
RotationDirection rotDir,
const Vec2f& dir2d)
const;
93 bool IsOutsideOnLeft(
const Vec2f& axis2d)
const;
94 bool IsOutsideOnRight(
const Vec2f& axis2d)
const;
96 bool IsOutsideOnLeft_Standard(
const Vec2f& axis2d)
const;
97 bool IsOutsideOnRight_Standard(
const Vec2f& axis2d)
const;
98 bool IsStrictlyInHalfPlan(
const Vec2f& refDir,
KyFloat32 rotSign,
const Vec2f& axis2d)
const;
99 bool IsInHalfPlan(
const Vec2f& refDir,
KyFloat32 rotSign,
const Vec2f& axis2d)
const;
101 enum IsInsideFunnelResult
103 FunnelNotInitialized,
104 LeftBorderNotInitialized,
105 RightBorderNotInitialized,
109 StrictlyInsideFunnel,
112 IsInsideFunnelResult IsInsideFunnel(
const Vec2f& axis2d,
KyFloat32 fullTurnToleranceSin)
const;
114 bool IsInsideFunnel(
const Vec2f& axis2d)
const;
116 void TightenLeftBorder(
const BubbleFunnelBorder& border);
117 void TightenRightBorder(
const BubbleFunnelBorder& border);
118 void PushBorderAsLineInDisplayList(
const BubbleFunnelBorder& border, ScopedDisplayList* displayList, VisualColor color);
122 const BubbleArray* m_bubbleArray;
127 FunnelSide m_apexSide;
133 BubbleFunnelBorder m_leftBorder;
134 BubbleFunnelBorder m_rightBorder;
137 FunnelResult m_previousResult;
140 Bubble m_lastAddedCornerBubble;
141 bool m_entryDirPassed;
142 bool m_hasQuitApexBubble;
145 ScopedDisplayList* m_leftBorderDisplayList;
146 ScopedDisplayList* m_rightBorderDisplayList;
150 KY_INLINE
void BubbleToCornerFunnel::TightenLeftBorder(
const BubbleFunnelBorder& border)
152 if (m_leftBorderDisplayList)
155 m_leftBorder = border;
156 m_previousResult = FunnelTightened;
159 KY_INLINE
void BubbleToCornerFunnel::TightenRightBorder(
const BubbleFunnelBorder& border)
161 if (m_rightBorderDisplayList)
164 m_rightBorder = border;
165 m_previousResult = FunnelTightened;
169 KY_INLINE
bool BubbleToCornerFunnel::IsOutsideOnLeft_Standard(
const Vec2f& axis2d)
const
171 return IsStrictlyInHalfPlan(m_leftBorder.GetSegmentDir2d(), 1.0f, axis2d);
174 KY_INLINE
bool BubbleToCornerFunnel::IsOutsideOnRight_Standard(
const Vec2f& axis2d)
const
176 return IsStrictlyInHalfPlan(m_rightBorder.GetSegmentDir2d(), -1.0f, axis2d);
181 #endif // Navigation_BubbleToCornerFunnel_H
Adaptive radius funnel to be used typically to string pull within a Bubble array. ...
Definition: bubbletocornerfunnel.h:74
This class encapsulate an array of Bubbles.
Definition: bubblearray.h:23
#define KY_NULL
Null value.
Definition: types.h:247
RotationDirection
Defines the 4 possible cases of possibly constrained rotation in the horizontal plane for a given ele...
Definition: rotation.h:20
This class defines a two-dimensional vector whose coordinates are stored using floating-point numbers...
Definition: vec2f.h:24
Definition: gamekitcrowddispersion.h:20
static const VisualColor Green
Represents the color with RGBA values ( 0, 128, 0, 255).
Definition: visualcolor.h:147
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
static const VisualColor DarkRed
Represents the color with RGBA values (139, 0, 0, 255).
Definition: visualcolor.h:127