7 #ifndef Navigation_Channel_H
8 #define Navigation_Channel_H
70 bool m_displayChannelIndex;
71 bool m_displaySectionIndex;
72 bool m_displayGateIndex;
73 bool m_displayExtremityPolylines;
74 bool m_displayOutline;
76 bool m_displayPathEdges;
77 bool m_displayPathNodes;
78 bool m_displayGateTypeLabel;
79 bool m_displayGateTypeColor;
80 bool m_displayChannelWidthLeft;
81 bool m_displayChannelWidthRight;
89 VisualShapeColor m_nodeColor;
97 VisualShapeColor m_channelWidthLeftColor;
98 VisualShapeColor m_channelWidthRightColor;
100 static const char* GetGateTypeText(
GateType gateType);
121 , m_rightPos(rightPos)
134 template <
class OSTREAM>
135 inline OSTREAM& operator<<(OSTREAM& os,
const Gate& g)
137 os <<
"[l=" << g.m_leftPos <<
", p=" << g.m_pathPos <<
", r=" << g.m_rightPos;
141 case StartGate : os <<
", type=StartGate ]";
break;
142 case EndGate : os <<
", type=EndGate ]";
break;
146 case LeftTurnEnd : os <<
", type=LeftTurnEnd ]";
break;
150 case RightTurnEnd : os <<
", type=RightTurnEnd ]";
break;
154 default: os <<
", !!! wrong gate type (" << g.m_type <<
") !!!]";
break;
174 class Channel :
public RefCountBase<Channel, MemStat_Channel>
178 : m_firstPathNodeIdx(0)
196 const Gate& GetSectionStartGate(
KyUInt32 sectionIdx)
const;
197 const Gate& GetSectionEndGate(
KyUInt32 sectionIdx)
const;
224 bool IsConcaveCorner(
KyUInt32 gateIdx, ChannelSide side)
const;
231 bool IntersectSegmentVsPreChannelPolyline(
const Vec2f& A,
const Vec2f& B,
Vec2f& intersection)
const;
232 bool IntersectSegmentVsPostChannelPolyline(
const Vec2f& A,
const Vec2f& B,
Vec2f& intersection)
const;
240 KyResult InitFromBlob(
const ChannelBlob& channelBlob);
244 void AddGate(
const Gate& gate);
250 void SetFirstPathNodeIdx(
KyUInt32 firstPathNodeIdx) { m_firstPathNodeIdx = firstPathNodeIdx; }
261 bool IsInsidePolyline(
const Vec2f& position,
const KyArray<Vec2f>& polyline)
const;
263 bool IntersectSegmentVsPolyline(
const Vec2f& A,
const Vec2f& B,
const KyArray<Vec2f>& polyline, Vec2f& intersection)
const;
264 bool IsPositionWithinSectionBorders(
const Vec2f& newPos2d,
const Vec2f& A,
const Vec2f& B,
const Vec2f& C,
const Vec2f& D)
const;
267 KyResult ComputeChannelWidth_LeftSideForward(
KyUInt32 gateIdx,
const Vec2f& computedGateLeftPos2d,
const Vec2f& computedGateRightPos2d,
KyFloat32& gateLeftSquareWidth);
268 KyResult ComputeChannelWidth_LeftSideBackward(
KyUInt32 gateIdx,
const Vec2f& computedGateLeftPos2d,
const Vec2f& computedGateRightPos2d,
KyFloat32& gateLeftSquareWidth);
271 KyResult ComputeChannelWidth_RightSideForward(
KyUInt32 gateIdx,
const Vec2f& computedGateLeftPos2d,
const Vec2f& computedGateRightPos2d,
KyFloat32& gateRightSquareWidth);
272 KyResult ComputeChannelWidth_RightSideBackward(
KyUInt32 gateIdx,
const Vec2f& computedGateLeftPos2d,
const Vec2f& computedGateRightPos2d,
KyFloat32& gateRightSquareWidth);
275 KyArray<Gate> m_gates;
276 KyArray<Vec2f> m_preChannelPolyline;
277 KyArray<Vec2f> m_postChannelPolyline;
281 KY_INLINE Channel::~Channel() { Clear(); }
283 KY_INLINE
KyUInt32 Channel::GetGateCount()
const {
return m_gates.GetCount(); }
284 KY_INLINE
const Gate& Channel::GetGate(
KyUInt32 index)
const {
return m_gates[index]; }
286 KY_INLINE
const KyArray<Vec2f>& Channel::GetPreChannelPolyline()
const {
return m_preChannelPolyline; }
287 KY_INLINE
const KyArray<Vec2f>& Channel::GetPostChannelPolyline()
const {
return m_postChannelPolyline; }
289 KY_INLINE
KyUInt32 Channel::GetSectionCount()
const {
KyUInt32 count = GetGateCount();
return (count ? (count + 1) : 0); }
290 KY_INLINE
KyUInt32 Channel::GetLastSectionIdx()
const {
return m_gates.GetCount(); }
291 KY_INLINE
KyUInt32 Channel::GetSectionStartGateIdx(
KyUInt32 sectionIdx)
const {
return Kaim::Max<KyUInt32>(sectionIdx, 1) - 1; }
292 KY_INLINE
KyUInt32 Channel::GetSectionEndGateIdx(
KyUInt32 sectionIdx)
const {
return Kaim::Min<KyUInt32>(sectionIdx, GetGateCount() - 1); }
293 KY_INLINE
const Gate& Channel::GetSectionStartGate(
KyUInt32 sectionIdx)
const {
return GetGate(GetSectionStartGateIdx(sectionIdx)); }
294 KY_INLINE
const Gate& Channel::GetSectionEndGate(
KyUInt32 sectionIdx)
const {
return GetGate(GetSectionEndGateIdx(sectionIdx)); }
296 KY_INLINE
const Vec3f&
Channel::GetEndPos()
const {
return m_gates[GetGateCount() - 1].m_pathPos; }
298 KY_INLINE
bool Channel::IntersectSegmentVsPreChannelPolyline(
const Vec2f& A,
const Vec2f& B, Vec2f& intersection)
const {
return IntersectSegmentVsPolyline(A, B, m_preChannelPolyline , intersection); }
299 KY_INLINE
bool Channel::IntersectSegmentVsPostChannelPolyline(
const Vec2f& A,
const Vec2f& B, Vec2f& intersection)
const {
return IntersectSegmentVsPolyline(A, B, m_postChannelPolyline, intersection); }
301 KY_INLINE
void Channel::Initialize() { Clear(); }
303 KY_INLINE
void Channel::Clear()
306 m_preChannelPolyline.Clear();
307 m_postChannelPolyline.Clear();
310 KY_INLINE
void Channel::AddGate(
const Gate& gate) { m_gates.PushBack(gate); }
311 KY_INLINE Gate& Channel::GetGate(
KyUInt32 index) {
return m_gates[index]; }
313 KY_INLINE
void Channel::SetPreChannelPolyline(
const KyArray<Vec2f>& polyline) { m_preChannelPolyline = polyline; }
314 KY_INLINE
void Channel::SetPostChannelPolyline(
const KyArray<Vec2f>& polyline) { m_postChannelPolyline = polyline; }
327 #endif // Navigation_Channel_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
Position is outside the section: it lays on the left of the left Border.
Definition: channel.h:58
Classes that configures the Channel visual debug display.
Definition: channel.h:64
Indicates the Gate is a right turn end.
Definition: channel.h:38
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
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
KyResult GetSectionFromPositionAndSeed_AlongBubble(const Bubble &bubble, const Kaim::Vec3f &previousPosition, KyUInt32 previousSectionIdx, const Kaim::Vec3f &newPosition, KyUInt32 &newSectionIdx) const
Given a previous position and its section, computes the section for a new position that is supposed t...
KyUInt32 GetGatePathNodeIdx(KyUInt32 gateIndex) const
Return PathNodeIdx of the gate at gateIndex.
Definition: channel.h:336
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
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:118
bool IsPositionInSection(const Vec2f &position, KyUInt32 sectionIndex, KyUInt32 &positionFlags) const
Checks a provided 2D position is inside a channel section.
KyResult GetSectionFromPositionAndSeed(const Kaim::Vec3f &previousPosition, KyUInt32 previousSectionIdx, const Kaim::Vec3f &newPosition, KyUInt32 &newSectionIdx) const
Given a previous position and its section, computes the section for a new position that is supposed t...
Represents a single RGBA color.
Definition: visualcolor.h:19
Indicates the Gate is a small turn to the left (CCW).
Definition: channel.h:30
This class is a runtime container for Gameware Navigation WorldElements such as NavData, Bots, BoxObstacles, TagVolumes...
Definition: world.h:54
Position is outside the section: it lays before the section start Gate.
Definition: channel.h:56
Indicates the Gate is a Channel start Gate.
Definition: channel.h:27
RelativePositionToChannelSectionFlag
Enumerates the Channel::IsPositionInSection relative position flags.
Definition: channel.h:52
This class represents a circle with potential rotation limitation.
Definition: bubble.h:35
const Vec3f & GetEndPos() const
Returns the channel end position, i.e.
Definition: channel.h:315
This class defines a two-dimensional vector whose coordinates are stored using floating-point numbers...
Definition: vec2f.h:24
Position is outside the section: it lays after the section end Gate.
Definition: channel.h:57
Indicates the Gate is a Channel width adjustment Gate. There is no direction modification there...
Definition: channel.h:40
A BlobArray an array that is compatible with the blob serialization framework.
Definition: blobarray.h:28
Definition: gamekitcrowddispersion.h:20
Channels define preferred navigation areas around an original Path section on NavMesh.
Definition: channel.h:177
KyUInt32 GetFirstPathNodeIdx() const
Return PathNodeIdx of the first gate.
Definition: channel.h:335
Position is inside the section.
Definition: channel.h:54
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
This class represents Channel section limit segment. See Channel class description.
Definition: channel.h:109
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
Position is outside the section: it lays on the right of the right Border.
Definition: channel.h:59
#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
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23