22 class RectangleIntersector
27 RectangleIntersector(BaseSegmentCastQuery& query) : m_maxDist(query.GetMaxDist())
29 const DatabaseGenMetrics& databaseGenMetrics = query.m_database->GetDatabaseGenMetrics();
31 m_integerPrecision = databaseGenMetrics.m_integerPrecision;
33 Vec2f ortho = query.GetNormalizedDir2d().PerpCCW();
34 m_startA.Set(query.GetStartPos().x + (ortho.x * query.GetRadius()), query.GetStartPos().y + (ortho.y * query.GetRadius()), query.GetStartPos().z);
35 m_startB.Set(query.GetStartPos().x - (ortho.x * query.GetRadius()), query.GetStartPos().y - (ortho.y * query.GetRadius()), query.GetStartPos().z);
37 m_rectangle = OrientedBox2d(m_startB, query.GetNormalizedDir2d(), m_maxDist, 2.f * query.GetRadius(), 0.f);
39 const Vec2f direction2f(query.GetNormalizedDir2d() * m_maxDist);
40 Vec2f destPos2f(query.GetStartPos().x + direction2f.x, query.GetStartPos().y + direction2f.y);
41 const CoordPos64 destCoordPos(databaseGenMetrics.GetCoordPos64FromVec2f(destPos2f));
43 databaseGenMetrics.GetCoordPos64FromVec3f(m_startB, m_o1);
44 const CoordPos64 startCoordPos = databaseGenMetrics.GetCoordPos64FromWorldIntegerPos(query.GetStartIntegerPos());
45 m_lengthVec = destCoordPos - startCoordPos;
46 m_widthVec = (startCoordPos - m_o1) * 2;
49 RectangleIntersector(BaseSegmentCanGoQuery& query)
51 const DatabaseGenMetrics& databaseGenMetrics = query.m_database->GetDatabaseGenMetrics();
53 m_integerPrecision = databaseGenMetrics.m_integerPrecision;
55 Vec2f dir(query.GetDestPos().x - query.GetStartPos().x, query.GetDestPos().y - query.GetStartPos().y);
58 Vec3f normalizedDir3D(dir.x, dir.y, 0.f);
60 const Vec3f o1Floats(query.GetStartPos() - (normalizedDir3D * query.GetRadius()));
62 databaseGenMetrics.GetCoordPos64FromVec3f(o1Floats, m_o1);
63 const CoordPos64 startCoordPos = databaseGenMetrics.GetCoordPos64FromWorldIntegerPos(query.GetStartIntegerPos());
64 m_lengthVec = databaseGenMetrics.GetCoordPos64FromWorldIntegerPos(query.GetDestIntegerPos()) - startCoordPos;
65 m_widthVec = (startCoordPos - m_o1) * 2;
70 return Math::IsSegmentVsOrientedBox2LL(startEdgeCoordPos, endEdgeCoordPos, m_o1, m_lengthVec, m_widthVec);
73 void ComputeCollisionPosOnEdge(
const CoordPos64& startEdgeCoordPos,
const CoordPos64& endEdgeCoordPos, Vec3f& collisionPos,
KyFloat32& squareDistToCollisionPos)
75 const Vec3f startEdgePos(startEdgeCoordPos.x * m_integerPrecision, startEdgeCoordPos.y * m_integerPrecision, 0.f);
76 const Vec3f endEdgePos(endEdgeCoordPos.x * m_integerPrecision, endEdgeCoordPos.y * m_integerPrecision, 0.f);
78 ClosestPoint::OnSegmentVsSegmentCast2d(startEdgePos, endEdgePos, m_startA, m_startB, m_maxDist, collisionPos, squareDistToCollisionPos);
83 const Vec3f v0(v0CoordPos.x * m_integerPrecision, v0CoordPos.y * m_integerPrecision, 0.f);
84 const Vec3f v1(v1CoordPos.x * m_integerPrecision, v1CoordPos.y * m_integerPrecision, 0.f);
85 const Vec3f v2(v2CoordPos.x * m_integerPrecision, v2CoordPos.y * m_integerPrecision, 0.f);
88 ClosestPoint::OnTriangleVsSegmentCast2d(v0, v1, v2, m_startA, m_startB, m_maxDist, unused, cost);
105 OrientedBox2d m_rectangle;
#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