12 #ifndef Navigation_ConeIntersector_H
13 #define Navigation_ConeIntersector_H
33 ConeIntersector(const Vec3f& startCenter, const Vec3f& endCenter,
KyFloat32 halfWidth,
KyFloat32 integerPrecision)
34 : m_integerPrecision(integerPrecision)
35 , m_startCenter(startCenter)
36 , m_endCenter(endCenter)
37 , m_halfWidth(halfWidth)
39 m_normalizedDir2d = m_endCenter.Get2d() - m_startCenter.Get2d();
40 m_length = m_normalizedDir2d.Normalize();
42 const Vec2f leftDir = m_normalizedDir2d.PerpCCW();
43 const Vec2f leftVec = m_halfWidth * leftDir;
44 m_endLeft = m_endCenter + leftVec;
45 m_endRight = m_endCenter - leftVec;
48 ConeIntersector(
const Vec3f& startPos,
const Vec2f& normalizedDir2d,
KyFloat32 length,
KyFloat32 halfWidth,
KyFloat32 integerPrecision)
49 : m_integerPrecision(integerPrecision)
50 , m_startCenter(startPos)
51 , m_normalizedDir2d(normalizedDir2d)
53 , m_halfWidth(halfWidth)
55 m_endCenter = m_startCenter + (m_normalizedDir2d * m_length);
57 const Vec2f leftDir = m_normalizedDir2d.PerpCCW();
58 const Vec2f leftVec = m_halfWidth * leftDir;
59 m_endLeft = m_endCenter + leftVec;
60 m_endRight = m_endCenter - leftVec;
65 const Vec3f startEdgePos(startEdgeCoordPos.x * m_integerPrecision, startEdgeCoordPos.y * m_integerPrecision, 0.f);
66 const Vec3f endEdgePos(endEdgeCoordPos.x * m_integerPrecision, endEdgeCoordPos.y * m_integerPrecision, 0.f);
68 return Intersections::SegmentVsTriangle2d(startEdgePos, endEdgePos, m_startCenter, m_endLeft, m_endRight);
71 void ComputeCollisionPosOnEdge(
const CoordPos64& startEdgeCoordPos,
const CoordPos64& endEdgeCoordPos, Vec3f& collisionPos,
KyFloat32& squareDistToCollisionPos)
73 const Vec3f startEdgePos(startEdgeCoordPos.x * m_integerPrecision, startEdgeCoordPos.y * m_integerPrecision, 0.f);
74 const Vec3f endEdgePos(endEdgeCoordPos.x * m_integerPrecision, endEdgeCoordPos.y * m_integerPrecision, 0.f);
76 ClosestPoint::OnSegmentVsConeCast2d(startEdgePos, endEdgePos, m_startCenter, m_normalizedDir2d, m_length, m_halfWidth, collisionPos, squareDistToCollisionPos);
81 const Vec3f v0(v0CoordPos.x * m_integerPrecision, v0CoordPos.y * m_integerPrecision, 0.f);
82 const Vec3f v1(v1CoordPos.x * m_integerPrecision, v1CoordPos.y * m_integerPrecision, 0.f);
83 const Vec3f v2(v2CoordPos.x * m_integerPrecision, v2CoordPos.y * m_integerPrecision, 0.f);
86 ClosestPoint::OnTriangleVsConeCast2d(v0, v1, v2, m_startCenter,m_normalizedDir2d, m_length, m_halfWidth, unused, cost);
97 Vec2f m_normalizedDir2d;
101 OrientedBox2d m_orientedBox2d;
108 #endif //Navigation_ConeIntersector_H
Vec2LL CoordPos64
A type that represents the position of a point within the 2D integer grid.
Definition: navmeshtypes.h:19
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43