gwnavruntime/channel/gatedefinition.h Source File

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