7 #ifndef Navigation_DiagonalStrip_H
8 #define Navigation_DiagonalStrip_H
47 class DiagonalStripPersistentDisplayListIds
50 DiagonalStripPersistentDisplayListIds()
63 ~DiagonalStripPersistentDisplayListIds() {}
65 void Initialize(World* world);
75 KyUInt32 m_displayListId_NearestOpposite;
76 KyUInt32 m_displayListId_DiskToNearestOpposite;
82 class DiagonalStripDisplayConfig
85 DiagonalStripDisplayConfig() { SetDefaults(); }
95 VisualShapeColor m_triangleColor;
96 VisualShapeColor m_leftColor;
97 VisualShapeColor m_rightColor;
98 VisualShapeColor m_cornerDiskColor;
99 VisualShapeColor m_diagonalColor;
101 DiagonalStripPersistentDisplayListIds m_persistentDisplayListIds;
123 : m_cornerType(UndefinedCornerType)
127 StripCorner(
const Vec3f& position, CornerType cornerType,
KyFloat32 maxRadius)
129 Set(position, cornerType, maxRadius);
132 static CornerType GetOppositeSide(CornerType cornerType)
136 case LeftSide:
return RightSide;
137 case RightSide:
return LeftSide;
138 default:
return cornerType;
142 void Set(
const Vec3f& position, CornerType cornerType,
KyFloat32 maxRadius)
144 m_position = position;
145 m_cornerType = cornerType;
146 m_maxRadius = maxRadius;
147 m_oppositeNearestPositionIsSet =
false;
150 void SetCornerNearestOppositePosition(
const Vec3f& nearestOppositePosition)
152 SetMaxRadius(0.49f *
Distance2d(m_position, nearestOppositePosition));
153 m_oppositeNearestPosition = nearestOppositePosition;
154 m_oppositeNearestPositionIsSet =
true;
159 m_maxRadius = maxRadius;
162 void PreciseType(CornerType cornerType) { m_cornerType = cornerType; }
164 const Vec3f& GetPosition()
const {
return m_position; }
165 CornerType GetCornerType()
const {
return m_cornerType; }
166 KyFloat32 GetMaxRadius()
const {
return m_maxRadius; }
168 bool IsOppositeNearestPositionSet()
const {
return m_oppositeNearestPositionIsSet; }
169 const Vec3f& GetOppositeNearestPosition()
const {
return m_oppositeNearestPosition; }
173 return (m_cornerType != UndefinedCornerType);
178 friend class DiagonalStrip;
181 CornerType m_cornerType;
184 Vec3f m_oppositeNearestPosition;
185 bool m_oppositeNearestPositionIsSet;
188 KY_INLINE
RotationDirection GetBubbleRotationDirectionFromCornerType(CornerType cornerType)
191 (cornerType == LeftSide) ? CounterClockwise :
192 (cornerType == RightSide) ? Clockwise :
193 UndefinedRotationDirection;
196 KY_INLINE FunnelSide GetFunnelSideFromCornerType(CornerType cornerType)
199 (cornerType == LeftSide) ? FunnelLeft :
200 (cornerType == RightSide) ? FunnelRight :
205 class NearestOppositePositionUpdator
208 NearestOppositePositionUpdator(
const Vec3f& position)
209 : m_position(position)
214 void UpdateWithOppositeSegment(
const Vec3f& A,
const Vec3f& B);
217 Vec3f m_nearestPosition;
233 NearestFoundIsStartOrEnd,
234 AskedCornerIsDiagonalStripStartOrEnd
241 void PushBackCorner(
const Vec3f& position, CornerType cornerType,
KyFloat32 maxRadius)
243 StripCorner corner(position, cornerType, maxRadius);
244 m_corners.PushBack(corner);
248 void SendVisualDebug(World* navWorld, DiagonalStripDisplayConfig& displayConfig);
250 bool IsEmpty()
const {
return m_corners.IsEmpty(); }
251 KyUInt32 GetCornerCount()
const {
return m_corners.GetCount(); }
252 const StripCorner& GetCorner(
KyUInt32 cornerIdx)
const {
return m_corners[cornerIdx]; }
253 StripCorner& GetCorner(
KyUInt32 cornerIdx) {
return m_corners[cornerIdx]; }
257 StripCorner GetIncomingBorderStart(
KyUInt32 cornerIdx)
const;
258 StripCorner GetOutgoingBorderEnd(
KyUInt32 cornerIdx)
const;
259 GetBorderResult GetNearestOppositeSidePosition(
KyUInt32 cornerIdx,
KyFloat32 searchRadius, Vec3f& nearestPosition)
const;
262 void SetCornerNearestOppositePosition(
KyUInt32 cornerIdx,
const Vec3f& nearestOppositePosition);
265 KyUInt32 GetLastCornerIdxOfType(CornerType cornerType);
266 void ChangePosOfLastCorner(CornerType cornerType,
const Vec3f& pos);
267 bool GetLastButOneCornerPos(CornerType cornerType, Vec3f& pos)
const;
268 StripCorner& GetLastCorner(CornerType cornerType);
270 void SendDiagonalStripVisualDebug(World* world, DiagonalStripDisplayConfig& displayConfig);
271 void ApplyToVisibleOppositeSegmentsForward(NearestOppositePositionUpdator& updator,
KyUInt32 cornerIdx,
KyFloat32 searchRadius)
const;
272 void ApplyToVisibleOppositeSegmentsBackward(NearestOppositePositionUpdator& updator,
KyUInt32 cornerIdx,
KyFloat32 searchRadius)
const;
274 KyArray<StripCorner> m_corners;
282 KY_INLINE
void DiagonalStrip::SetCornerRadius(
KyUInt32 cornerIdx,
KyFloat32 cornerRadius)
284 KY_ASSERT(cornerIdx < m_corners.GetCount());
285 m_corners[cornerIdx].m_maxRadius = cornerRadius;
288 KY_INLINE
void DiagonalStrip::SetCornerNearestOppositePosition(
KyUInt32 cornerIdx,
const Vec3f& nearestOppositePosition)
290 KY_ASSERT(cornerIdx < m_corners.GetCount());
291 m_corners[cornerIdx].SetCornerNearestOppositePosition(nearestOppositePosition);
294 KY_INLINE
void DiagonalStrip::SetCornerMaxRadius(
KyUInt32 cornerIdx,
KyFloat32 maxRadius)
296 KY_ASSERT(cornerIdx < m_corners.GetCount());
297 m_corners[cornerIdx].SetMaxRadius(maxRadius);
301 inline KyUInt32 DiagonalStrip::GetLastCornerIdxOfType(CornerType cornerType)
303 KY_ASSERT(GetCornerCount() > 0);
304 KyUInt32 cornerIdx = GetCornerCount() - 1;
307 StripCorner& corner = GetCorner(cornerIdx);
308 if (corner.GetCornerType() == cornerType)
318 inline void DiagonalStrip::ChangePosOfLastCorner(CornerType cornerType,
const Vec3f& pos)
320 KY_ASSERT(GetCornerCount() > 0);
321 KyUInt32 cornerIdx = GetCornerCount() - 1;
324 StripCorner& corner = GetCorner(cornerIdx);
325 if (corner.GetCornerType() == cornerType)
327 corner.m_position = pos;
338 inline StripCorner& DiagonalStrip::GetLastCorner(CornerType cornerType)
340 KY_ASSERT(GetCornerCount() > 0);
341 KyUInt32 cornerIdx = GetCornerCount() - 1;
344 StripCorner& corner = GetCorner(cornerIdx);
345 if (corner.GetCornerType() == cornerType)
352 inline bool DiagonalStrip::GetLastButOneCornerPos(CornerType cornerType, Vec3f& pos)
const
354 KY_ASSERT(GetCornerCount() > 0);
355 KyUInt32 cornerIdx = GetCornerCount() - 1;
356 bool foundOne =
false;
359 const StripCorner& corner = GetCorner(cornerIdx);
360 if (corner.GetCornerType() == cornerType)
364 pos = corner.GetPosition();
382 #endif // Navigation_DiagonalStrip_H
#define KyFloat32MAXVAL
The maximum value that can be stored in the KyFloat32 variable type.
Definition: types.h:227
KyFloat32 Distance2d(const Vec3f &v1, const Vec3f &v2)
Returns the distance between v1 and v2, ignoring Z coordinates.
Definition: vec3f.h:288
#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
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#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