gwnavruntime/queries/utils/polygonintersector.h Source File
Go to the documentation of this file.
20 class PolygonIntersector
25 PolygonIntersector(const Vec2f* points,
KyUInt32 pointCount,
KyFloat32 integerPrecision)
29 bool inputPolylineIsClosed = points[0] == points[pointCount-1];
30 m_points.Resize(inputPolylineIsClosed ? pointCount : pointCount+1);
32 for(
KyUInt32 i = 0; i < pointCount; ++i)
34 m_points[i] = points[i];
35 m_box2f.ExpandByPos(points[i]);
38 if (inputPolylineIsClosed ==
false)
39 m_points[pointCount] = points[0];
42 m_integerPrecision = integerPrecision;
47 const Vec2f startEdgePos(startEdgeCoordPos.x * m_integerPrecision, startEdgeCoordPos.y * m_integerPrecision);
48 const Vec2f endEdgePos(endEdgeCoordPos.x * m_integerPrecision, endEdgeCoordPos.y * m_integerPrecision);
51 Kaim::Min(startEdgePos.x, endEdgePos.x), Kaim::Min(startEdgePos.y, endEdgePos.y),
52 Kaim::Max(startEdgePos.x, endEdgePos.x), Kaim::Max(startEdgePos.y, endEdgePos.y));
54 if (Math::IsBoxVsBox2f(m_box2f, edgeBox) ==
false)
57 if (IsPointInsidePolyline(startEdgePos))
60 if (IsPointInsidePolyline(endEdgePos))
63 return DoesEdgeIntersectOnePolylineBorder(startEdgePos, endEdgePos);
66 bool IsPointInsidePolyline(
const Vec2f& point)
68 if (m_box2f.DoesContain(point) ==
false)
71 return ClosedContour::DoesContain2f(point, m_points.GetDataPtr(), m_points.GetCount());
74 bool DoesEdgeIntersectOnePolylineBorder(
const Vec2f& startEdgePos,
const Vec2f& endEdgePos)
76 KyUInt32 pointCount = m_points.GetCount();
77 for(
KyUInt32 i = 0; i < pointCount - 1; ++i)
79 if (Math::IsSegmentVsSegment2f(m_points[i], m_points[i+1], startEdgePos, endEdgePos))
86 KyArrayPOD<Vec2f> m_points;
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Vec2LL CoordPos64
A type that represents the position of a point within the 2D integer grid.
Definition: navmeshtypes.h:16
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
float KyFloat32
float
Definition: types.h:32