18 class DisplayListManager;
19 class DisplayListIdArray;
21 class DiagonalStripDisplayListIds
24 DiagonalStripDisplayListIds()
35 void RemoveAll(DisplayListManager* displayListManager);
48 class DiagonalStripDisplayConfig
51 DiagonalStripDisplayConfig() { SetDefaults(); }
55 ShapeColor m_triangleColor;
58 ShapeColor m_cornerDiskColor;
59 ShapeColor m_diagonalColor;
76 : m_cornerType(UndefinedCornerType)
80 StripCorner(
const Vec3f& position, CornerType cornerType,
KyFloat32 maxRadius)
82 Set(position, cornerType, maxRadius);
85 static CornerType GetOppositeSide(CornerType cornerType)
89 case LeftSide:
return RightSide;
90 case RightSide:
return LeftSide;
91 default:
return cornerType;
95 void Set(
const Vec3f& position, CornerType cornerType,
KyFloat32 maxRadius)
97 m_position = position;
98 m_cornerType = cornerType;
99 m_maxRadius = maxRadius;
100 m_oppositeNearestPositionIsSet =
false;
103 void SetCornerNearestOppositePosition(
const Vec3f& nearestOppositePosition)
105 SetMaxRadius(0.49f * Distance2d(m_position, nearestOppositePosition));
106 m_oppositeNearestPosition = nearestOppositePosition;
107 m_oppositeNearestPositionIsSet =
true;
112 m_maxRadius = maxRadius;
115 void PreciseType(CornerType cornerType) { m_cornerType = cornerType; }
117 const Vec3f& GetPosition()
const {
return m_position; }
118 CornerType GetCornerType()
const {
return m_cornerType; }
119 KyFloat32 GetMaxRadius()
const {
return m_maxRadius; }
121 bool IsOppositeNearestPositionSet()
const {
return m_oppositeNearestPositionIsSet; }
122 const Vec3f& GetOppositeNearestPosition()
const {
return m_oppositeNearestPosition; }
126 return (m_cornerType != UndefinedCornerType);
131 friend class DiagonalStrip;
134 CornerType m_cornerType;
137 Vec3f m_oppositeNearestPosition;
138 bool m_oppositeNearestPositionIsSet;
141 KY_INLINE
RotationDirection GetBubbleRotationDirectionFromCornerType(CornerType cornerType)
144 (cornerType == LeftSide) ? CounterClockwise :
145 (cornerType == RightSide) ? Clockwise :
146 UndefinedRotationDirection;
149 KY_INLINE FunnelSide GetFunnelSideFromCornerType(CornerType cornerType)
152 (cornerType == LeftSide) ? FunnelLeft :
153 (cornerType == RightSide) ? FunnelRight :
158 class NearestOppositePositionUpdator
161 NearestOppositePositionUpdator(
const Vec3f& position)
162 : m_position(position)
167 void UpdateWithOppositeSegment(
const Vec3f& A,
const Vec3f& B);
170 Vec3f m_nearestPosition;
182 NearestFoundIsStartOrEnd,
183 AskedCornerIsDiagonalStripStartOrEnd
188 void PushBackCorner(
const Vec3f& position, CornerType cornerType,
KyFloat32 maxRadius)
190 StripCorner corner(position, cornerType, maxRadius);
191 m_corners.PushBack(corner);
195 void SendVisualDebug(DisplayListManager* displayListManager, DiagonalStripDisplayListIds& displayListIds,
const DiagonalStripDisplayConfig& displayConfig = DiagonalStripDisplayConfig());
197 bool IsEmpty()
const {
return m_corners.IsEmpty(); }
198 KyUInt32 GetCornerCount()
const {
return m_corners.GetCount(); }
199 const StripCorner& GetCorner(
KyUInt32 cornerIdx)
const {
return m_corners[cornerIdx]; }
200 StripCorner& GetCorner(
KyUInt32 cornerIdx) {
return m_corners[cornerIdx]; }
204 StripCorner GetIncomingBorderStart(
KyUInt32 cornerIdx)
const;
205 StripCorner GetOutgoingBorderEnd(
KyUInt32 cornerIdx)
const;
206 GetBorderResult GetNearestOppositeSidePosition(
KyUInt32 cornerIdx,
KyFloat32 searchRadius, Vec3f& nearestPosition)
const;
208 void SetCornerRadius(
KyUInt32 cornerIdx,
KyFloat32 cornerRadius) { m_corners[cornerIdx].m_maxRadius = cornerRadius; }
209 void SetCornerNearestOppositePosition(
KyUInt32 cornerIdx,
const Vec3f& pos) { m_corners[cornerIdx].SetCornerNearestOppositePosition(pos); }
210 void SetCornerMaxRadius(
KyUInt32 cornerIdx,
KyFloat32 maxRadius) { m_corners[cornerIdx].SetMaxRadius(maxRadius); }
212 KyUInt32 GetLastCornerIdxOfType(CornerType cornerType);
213 void ChangePosOfLastCorner(CornerType cornerType,
const Vec3f& pos);
214 bool GetLastButOneCornerPos(CornerType cornerType, Vec3f& pos)
const;
215 StripCorner& GetLastCorner(CornerType cornerType);
218 void SendDiagonalStripVisualDebug(DisplayListManager* displayListManager, DiagonalStripDisplayListIds& displayListIds,
const DiagonalStripDisplayConfig& displayConfig);
219 void ApplyToVisibleOppositeSegmentsForward(NearestOppositePositionUpdator& updator,
KyUInt32 cornerIdx,
KyFloat32 searchRadius)
const;
220 void ApplyToVisibleOppositeSegmentsBackward(NearestOppositePositionUpdator& updator,
KyUInt32 cornerIdx,
KyFloat32 searchRadius)
const;
223 KyArray<StripCorner> m_corners;
227 inline KyUInt32 DiagonalStrip::GetLastCornerIdxOfType(CornerType cornerType)
229 KY_ASSERT(GetCornerCount() > 0);
230 KyUInt32 cornerIdx = GetCornerCount() - 1;
233 StripCorner& corner = GetCorner(cornerIdx);
234 if (corner.GetCornerType() == cornerType)
244 inline void DiagonalStrip::ChangePosOfLastCorner(CornerType cornerType,
const Vec3f& pos)
246 KY_ASSERT(GetCornerCount() > 0);
247 KyUInt32 cornerIdx = GetCornerCount() - 1;
250 StripCorner& corner = GetCorner(cornerIdx);
251 if (corner.GetCornerType() == cornerType)
253 corner.m_position = pos;
264 inline StripCorner& DiagonalStrip::GetLastCorner(CornerType cornerType)
266 KY_ASSERT(GetCornerCount() > 0);
267 KyUInt32 cornerIdx = GetCornerCount() - 1;
270 StripCorner& corner = GetCorner(cornerIdx);
271 if (corner.GetCornerType() == cornerType)
278 inline bool DiagonalStrip::GetLastButOneCornerPos(CornerType cornerType, Vec3f& pos)
const
280 KY_ASSERT(GetCornerCount() > 0);
281 KyUInt32 cornerIdx = GetCornerCount() - 1;
282 bool foundOne =
false;
285 const StripCorner& corner = GetCorner(cornerIdx);
286 if (corner.GetCornerType() == cornerType)
290 pos = corner.GetPosition();
#define KyFloat32MAXVAL
KyFloat32 max value
Definition: types.h:71
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
RotationDirection
Defines the 4 possible cases of possibly constrained rotation in the horizontal plane for a given ele...
Definition: rotation.h:15
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
#define KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68
float KyFloat32
float
Definition: types.h:32