gwnavruntime/channel/funnel.h Source File

funnel.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 #ifndef Navigation_Funnel_H
8 #define Navigation_Funnel_H
9 
11 
12 
13 namespace Kaim
14 {
15 
16 enum FunnelDirection
17 {
18  ForwardFunnel,
19  BackwardFunnel
20 };
21 
22 enum FunnelResult
23 {
24  FunnelError, // The funnel failed to update with the last provided corner.
25  FunnelIgnored, // The last provided corner has been ignored (e.g. it lays inside the apex bubble).
26  FunnelUnchanged, // The last provided corner did not change the funnel (e.g. a right corner on the right of the current left-most right corner).
27  FunnelTightened, // The last provided corner has tighten the funnel (e.g. a right corner that lay on the left of the former left-most right corner and on the right of the current right-most left corner, that is now the new left-most right corner).
28  FunnelClosedOverRight, // The last provided corner has closed the funnel over its left-most right corner.
29  FunnelClosedOverLeft // The last provided corner has closed the funnel over its right-most left corner.
30 };
31 KY_INLINE static bool IsClosureCase(FunnelResult result) { return ((result == FunnelClosedOverRight) || (result == FunnelClosedOverLeft)); }
32 
33 enum FunnelSide
34 {
35  UndefinedFunnelSide,
36  FunnelLeft,
37  FunnelRight,
38  FunnelBothSides // start and end corners are collapsed and impact both sides of the funnel.
39 };
40 
41 
43 class Funnel
44 {
45 public:
46  Funnel()
47  : m_apexIdx(0)
48  , m_leftCornerIdx(0)
49  , m_rightCornerIdx(0)
50  , m_apexSide(UndefinedFunnelSide)
51  , m_funnelDirection(ForwardFunnel)
52  , m_previousResult(FunnelUnchanged)
53  , m_isLeftBorderInitialized(false)
54  , m_isRightBorderInitialized(false)
55  {}
56 
57  void Initialize(KyUInt32 apexIdx, FunnelSide apexSide, FunnelDirection funnelDirection = ForwardFunnel);
58  FunnelResult Update(const Vec2f& vecToCorner, KyUInt32 idx, FunnelSide side);
59 
60  FunnelDirection GetFunnelDirection() const { return m_funnelDirection; }
61  KyUInt32 GetApexIdx() const { return m_apexIdx; }
62  FunnelSide GetApexSide() const { return m_apexSide; }
63  KyUInt32 GetLeftCornerIdx() const { return m_leftCornerIdx; }
64  KyUInt32 GetRightCornerIdx() const { return m_rightCornerIdx; }
65  FunnelResult GetPreviousResult() const { return m_previousResult; }
66 
67 private:
68  void TightenLeftBorder(const Vec2f& vecToCorner, KyUInt32 cornerIdx);
69  void TightenRightBorder(const Vec2f& vecToCorner, KyUInt32 cornerIdx);
70 
71  bool IsOutsideOnLeft(const Vec2f& axis2d) const;
72  bool IsOutsideOnRight(const Vec2f& axis2d) const;
73 
74  void ResolveActualClosureCase(FunnelResult naturalClosure);
75 
76 
77 private:
78  Vec2f m_vec2dToLeft;
79  Vec2f m_vec2dToRight;
80 
81  KyUInt32 m_apexIdx;
82  KyUInt32 m_leftCornerIdx;
83  KyUInt32 m_rightCornerIdx;
84 
85  FunnelSide m_apexSide;
86  FunnelDirection m_funnelDirection;
87 
88  FunnelResult m_previousResult;
89 
90  bool m_isLeftBorderInitialized;
91  bool m_isRightBorderInitialized;
92 };
93 
94 
95 } // namespace Kaim
96 
97 #endif // Navigation_Funnel_H
This class defines a two-dimensional vector whose coordinates are stored using floating-point numbers...
Definition: vec2f.h:24
Basic straight line funnel acting directly on 2D positions.
Definition: funnel.h:43
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36