9 #ifndef Navigation_PolygonIntersector_H
10 #define Navigation_PolygonIntersector_H
22 class PolygonIntersector
27 PolygonIntersector(const Vec2f* points,
KyUInt32 pointCount,
KyFloat32 integerPrecision)
31 bool inputPolylineIsClosed = points[0] == points[pointCount-1];
32 m_points.Resize(inputPolylineIsClosed ? pointCount : pointCount+1);
34 for(
KyUInt32 i = 0; i < pointCount; ++i)
36 m_points[i] = points[i];
37 m_box2f.ExpandByVec2(points[i]);
40 if (inputPolylineIsClosed ==
false)
41 m_points[pointCount] = points[0];
44 m_integerPrecision = integerPrecision;
49 const Vec2f startEdgePos(startEdgeCoordPos.x * m_integerPrecision, startEdgeCoordPos.y * m_integerPrecision);
50 const Vec2f endEdgePos(endEdgeCoordPos.x * m_integerPrecision, endEdgeCoordPos.y * m_integerPrecision);
56 if (Intersections::AABBVsAABB2d(m_box2f, edgeBox) ==
false)
59 if (IsPointInsidePolyline(startEdgePos))
62 if (IsPointInsidePolyline(endEdgePos))
65 return DoesEdgeIntersectOnePolylineBorder(startEdgePos, endEdgePos);
68 bool IsPointInsidePolyline(
const Vec2f& point)
70 if (m_box2f.IsPoint2DInside(point) ==
false)
73 return GeometryFunctions::IsInside2d_Polyline(point, m_points.GetDataPtr(), m_points.GetCount());
76 bool DoesEdgeIntersectOnePolylineBorder(
const Vec2f& startEdgePos,
const Vec2f& endEdgePos)
78 KyUInt32 pointCount = m_points.GetCount();
79 for(
KyUInt32 i = 0; i < pointCount - 1; ++i)
81 if (Intersections::SegmentVsSegment2d(m_points[i], m_points[i+1], startEdgePos, endEdgePos))
88 KyArrayPOD<Vec2f> m_points;
97 #endif //Navigation_PolygonIntersector_H
T Min(const T &a, const T &b)
Returns the lesser of the two specified values.
Definition: fastmath.h:113
Vec2LL CoordPos64
A type that represents the position of a point within the 2D integer grid.
Definition: navmeshtypes.h:19
T Max(const T &a, const T &b)
Returns the greater of the two specified values.
Definition: fastmath.h:121
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43