gwnavruntime/channel/gatedefinition.h Source File

gatedefinition.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 
13 
14 namespace Kaim
15 {
16 
17 class DisplayListManager;
18 
19 // A GateDefinition contains all necessary information to compute a gate at a given
20 // place along the string-pulled path.
21 class GateDefinition
22 {
23 public:
24  GateDefinition();
25  GateDefinition(GateType type, const Vec3f& pathPos, const Vec2f& gateLeftDir);
26  GateDefinition(GateType type, const Vec3f& pathPos, const Vec3f& turnInnerPos, const Vec2f& gateLeftDir);
27 
28  GateType GetGateType() const { return m_gateType; }
29  const Vec3f& GetPathPos() const { return m_pathPos; }
30  const Vec3f& GetTurnInnerPos() const { return m_turnInnerPos; }
31  const Vec2f& GetGateLeftDir() const { return m_gateLeftDir; }
32 
33 private:
34  Vec3f m_pathPos;
35  Vec3f m_turnInnerPos;
36  Vec2f m_gateLeftDir;
37  GateType m_gateType;
38 };
39 
40 template <class OSTREAM>
41 inline OSTREAM& operator<<(OSTREAM& os, const GateDefinition& g)
42 {
43  os << "[p=" << g.GetPathPos() << ", t=" << g.GetTurnInnerPos() << ", lDir=" << g.GetGateLeftDir();
44  switch (g.GetGateType())
45  {
46  case UndefinedGateType : os << ", type=UndefinedGateType ]"; break;
47  case StartGate : os << ", type=StartGate ]"; break;
48  case EndGate : os << ", type=EndGate ]"; break;
49  case SmallLeftTurn : os << ", type=SmallLeftTurn ]"; break;
50  case LeftTurnStart : os << ", type=LeftTurnStart ]"; break;
51  case LeftTurnIntermediary : os << ", type=LeftTurnIntermediary ]"; break;
52  case LeftTurnEnd : os << ", type=LeftTurnEnd ]"; break;
53  case SmallRightTurn : os << ", type=SmallRightTurn ]"; break;
54  case RightTurnStart : os << ", type=RightTurnStart ]"; break;
55  case RightTurnIntermediary: os << ", type=RightTurnIntermediary]"; break;
56  case RightTurnEnd : os << ", type=RightTurnEnd ]"; break;
57  case WidthAdjustment : os << ", type=WidthAdjustment ]"; break;
58  case ClampingAdjustment : os << ", type=ClampingAdjustment ]"; break;
59 
60  default: os << ", !!! wrong gate type (" << g.GetGateType() << ") !!!]"; break;
61  }
62 
63  return os;
64 }
65 
66 class GateDefinitionPersistentDisplayListIds
67 {
68 public:
69  GateDefinitionPersistentDisplayListIds()
70  : m_displayListManager(nullptr)
71  , m_singleFrame(true)
72  , m_displayListId_Nodes(KyUInt32MAXVAL)
73  , m_displayListId_Edges(KyUInt32MAXVAL)
74  , m_displayListId_TurnInnerPos(KyUInt32MAXVAL)
75  , m_displayListId_LeftDirs(KyUInt32MAXVAL)
76  {}
77 
78  ~GateDefinitionPersistentDisplayListIds() {}
79 
80  void Initialize(DisplayListManager* displayListManager);
81  void Release();
82 
83 public:
84  DisplayListManager* m_displayListManager;
85  bool m_singleFrame;
86 
87  KyUInt32 m_displayListId_Nodes;
88  KyUInt32 m_displayListId_Edges;
89  KyUInt32 m_displayListId_TurnInnerPos;
90  KyUInt32 m_displayListId_LeftDirs;
91 };
92 
93 class GateDefinitionDisplayConfig
94 {
95 public:
96  GateDefinitionDisplayConfig() { SetDefaults(); }
97 
98  void SetDefaults();
99 
100  Color m_pathPosColor;
101  Color m_turnInnerPosColor;
102  Color m_leftDirColor;
103  Color m_pathEdgeColor;
104  Color m_pathToTurnInnerPosColor_Left;
105  Color m_pathToTurnInnerPosColor_Right;
106 
107  Color m_gateTypeColor[GATE_TYPE_COUNT];
108 
109  KyFloat32 m_pathPosRadius;
110  KyFloat32 m_turnInnerPosRadius;
111  KyFloat32 m_leftDirArrowWidth;
112 
113  GateDefinitionPersistentDisplayListIds m_persistentDisplayListIds;
114 };
115 
116 class GateDefinitionArray : public RefCountBase<GateDefinitionArray, MemStat_Channel>
117 {
118 public:
119  GateDefinitionArray() : m_displayListManager(nullptr) {}
120 
121  void Clear() { m_gateDefinitions.Clear(); }
122 
123  void PushBack(const GateDefinition& gateDefinition);
124 
125  bool IsEmpty() const { return m_gateDefinitions.IsEmpty(); }
126  KyUInt32 GetGateDefinitionCount() const { return m_gateDefinitions.GetCount(); }
127  const GateDefinition& GetGateDefinition(KyUInt32 idx) const { return m_gateDefinitions[idx]; }
128 
129  void SendVisualDebug(const GateDefinitionDisplayConfig& displayConfig, const char* groupName, KyUInt32 visualDebugId = KyUInt32MAXVAL) const;
130 
131 private:
132  KyArray<GateDefinition> m_gateDefinitions;
133 
134 public:
135  FullDebug m_fullDebug;
136  DisplayListManager* m_displayListManager;
137 };
138 
139 } // namespace Kaim
140 
Indicates the Gate is the start of a sampled turn to the left (CCW). The next Gate must have either L...
Definition: channel.h:28
Indicates the Gate is a right turn end.
Definition: channel.h:35
GateType
Enumerates the different kind of Gates.
Definition: channel.h:20
Indicates the Gate is a left turn end.
Definition: channel.h:30
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
Indicates the Gate is a sampled left turn intermediary Gate.
Definition: channel.h:29
Indicates the Gate is the start of a sampled turn to the right (CW). The next Gate must have either R...
Definition: channel.h:33
Indicates the Gate is not defined.
Definition: channel.h:22
Indicates the Gate is a small turn to the left (CCW).
Definition: channel.h:27
Indicates the Gate is a Channel start Gate.
Definition: channel.h:24
Indicates the Gate is a Channel width adjustment Gate. There is no direction modification there...
Definition: channel.h:37
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Indicates the Gate is a small turn to the right (clockwise).
Definition: channel.h:32
Indicates the Gate is a Channel end Gate.
Definition: channel.h:25
Indicates the Gate is a Channel altitude clamping adjustment Gate. There is no direction modification...
Definition: channel.h:38
Indicates the Gate is a sampled right turn intermediary Gate.
Definition: channel.h:34
#define KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68
float KyFloat32
float
Definition: types.h:32