18 class CapsuleIntersector
23 CapsuleIntersector(const Vec3f& startPos, const Vec3f& endPos,
KyFloat32 radius,
KyFloat32 integerPrecision)
24 : m_integerPrecision(integerPrecision)
25 , m_startCenter(startPos)
30 Vec3f dir(m_endCenter - m_startCenter);
32 m_dist = dir.Normalize();
34 const Vec3f normalizedDir3D_ortho(-dir.y, dir.x, 0.f);
35 const Vec3f box_a(m_startCenter - (normalizedDir3D_ortho * m_radius));
37 m_orientedBox2d.Set(box_a, Vec2f(dir.x, dir.y), m_dist, m_radius * 2.f, 0.f);
40 CapsuleIntersector(
const Vec3f& startPos,
const Vec2f& normalizedDir2d,
KyFloat32 dist,
KyFloat32 radius,
KyFloat32 integerPrecision)
41 : m_integerPrecision(integerPrecision)
42 , m_startCenter(startPos)
43 , m_normalizedDir2d(normalizedDir2d)
47 const Vec3f normalizedDir3D_ortho(-m_normalizedDir2d.y, m_normalizedDir2d.x, 0.f);
48 const Vec3f box_a(m_startCenter - (normalizedDir3D_ortho * m_radius));
49 m_orientedBox2d.Set(box_a, m_normalizedDir2d, m_dist, m_radius * 2.f, 0.f);
51 const Vec3f normalizedDir3D(m_normalizedDir2d.x, m_normalizedDir2d.y, 0.f);
52 m_endCenter = m_startCenter + (normalizedDir3D * m_dist);
57 const Vec3f startEdgePos(startEdgeCoordPos.x * m_integerPrecision, startEdgeCoordPos.y * m_integerPrecision, 0.f);
58 const Vec3f endEdgePos(endEdgeCoordPos.x * m_integerPrecision, endEdgeCoordPos.y * m_integerPrecision, 0.f);
60 return Math::SegmentVsCapsule2f(startEdgePos, endEdgePos, m_orientedBox2d, m_startCenter, m_endCenter, m_radius);
63 void ComputeCollisionPosOnEdge(
const CoordPos64& startEdgeCoordPos,
const CoordPos64& endEdgeCoordPos, Vec3f& collisionPos,
KyFloat32& squareDistToCollisionPos)
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 ClosestPoint::OnSegmentVsDiskCast2d(startEdgePos, endEdgePos, m_startCenter, m_radius, m_normalizedDir2d, m_dist, collisionPos, squareDistToCollisionPos);
73 const Vec3f v0(v0CoordPos.x * m_integerPrecision, v0CoordPos.y * m_integerPrecision, 0.f);
74 const Vec3f v1(v1CoordPos.x * m_integerPrecision, v1CoordPos.y * m_integerPrecision, 0.f);
75 const Vec3f v2(v2CoordPos.x * m_integerPrecision, v2CoordPos.y * m_integerPrecision, 0.f);
78 ClosestPoint::OnTriangleVsDiskCast2d(v0, v1, v2, m_startCenter, m_radius, m_normalizedDir2d, m_dist, unused, cost);
86 Vec2f m_normalizedDir2d;
90 OrientedBox2d m_orientedBox2d;
#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