18 class CrossedSectionCapsuleIntersector
23 CrossedSectionCapsuleIntersector(const BaseDiskCastQuery& query,
KyFloat32 distOnRight,
KyFloat32 distOnLeft) :
24 m_integerPrecision(query.m_database->GetDatabaseGenMetrics().m_integerPrecision), m_startCenter(query.GetStartPos()), m_normalizedDir2d(query.GetNormalizedDir2d()),
25 m_dist(query.GetMaxDist()), m_radius(query.GetRadius())
27 const Vec2f normalizedDir_ortho(m_normalizedDir2d.PerpCCW());
28 const Vec3f normalizedDir3D(m_normalizedDir2d.x, m_normalizedDir2d.y, 0.f);
29 const Vec3f normalizedDir3D_ortho(normalizedDir_ortho.x, normalizedDir_ortho.y, 0.f);
31 m_centerOfTheEndHalfDisk = m_startCenter + (normalizedDir3D * m_dist);
33 const Vec3f orientedBox2d_a(m_startCenter - (normalizedDir3D_ortho * distOnRight));
34 const Vec3f m_BBoxOfTheEndHalfDisk_a(m_centerOfTheEndHalfDisk - (normalizedDir3D_ortho * distOnRight));
36 m_orientedBox2d.Set(orientedBox2d_a, m_normalizedDir2d, m_dist, distOnRight + distOnLeft, 0.f);
37 m_BBoxOfTheEndHalfDisk.Set(m_BBoxOfTheEndHalfDisk_a, m_normalizedDir2d, m_radius, distOnRight + distOnLeft, 0.f);
40 CrossedSectionCapsuleIntersector(
const BaseDiskCanGoQuery& query,
KyFloat32 distOnRight,
KyFloat32 distOnLeft) :
41 m_integerPrecision(query.m_database->GetDatabaseGenMetrics().m_integerPrecision), m_startCenter(query.GetStartPos()), m_radius(query.GetRadius())
43 Vec3f dir(query.GetDestPos() - query.GetStartPos());
45 m_dist = dir.Normalize();
46 m_normalizedDir2d.Set(dir.x, dir.y);
48 const Vec2f normalizedDir_ortho(m_normalizedDir2d.PerpCCW());
49 const Vec3f normalizedDir3D(m_normalizedDir2d.x, m_normalizedDir2d.y, 0.f);
50 const Vec3f normalizedDir3D_ortho(normalizedDir_ortho.x, normalizedDir_ortho.y, 0.f);
52 m_centerOfTheEndHalfDisk = m_startCenter + (normalizedDir3D * m_dist);
54 const Vec3f orientedBox2d_a(m_startCenter - (normalizedDir3D_ortho * distOnRight));
55 const Vec3f m_BBoxOfTheEndHalfDisk_a(m_centerOfTheEndHalfDisk - (normalizedDir3D_ortho * distOnRight));
57 m_orientedBox2d.Set(orientedBox2d_a, m_normalizedDir2d, m_dist, distOnRight + distOnLeft, 0.f);
58 m_BBoxOfTheEndHalfDisk.Set(m_BBoxOfTheEndHalfDisk_a, m_normalizedDir2d, m_radius, distOnRight + distOnLeft, 0.f);
63 const Vec3f startEdgePos(startEdgeCoordPos.x * m_integerPrecision, startEdgeCoordPos.y * m_integerPrecision, 0.f);
64 const Vec3f endEdgePos(endEdgeCoordPos.x * m_integerPrecision, endEdgeCoordPos.y * m_integerPrecision, 0.f);
66 return Math::SegmentVsCrossSectionCapsule2f(startEdgePos, endEdgePos, m_orientedBox2d, m_centerOfTheEndHalfDisk, m_radius, m_BBoxOfTheEndHalfDisk);
69 void ComputeCollisionPosOnEdge(
const CoordPos64& startEdgeCoordPos,
const CoordPos64& endEdgeCoordPos, Vec3f& collisionPos,
KyFloat32& squareDistToCollisionPos)
71 const Vec3f startEdgePos(startEdgeCoordPos.x * m_integerPrecision, startEdgeCoordPos.y * m_integerPrecision, 0.f);
72 const Vec3f endEdgePos(endEdgeCoordPos.x * m_integerPrecision, endEdgeCoordPos.y * m_integerPrecision, 0.f);
74 ClosestPoint::OnSegmentVsDiskCast2d(startEdgePos, endEdgePos, m_startCenter, m_radius, m_normalizedDir2d, m_dist, collisionPos, squareDistToCollisionPos);
79 const Vec3f v0(v0CoordPos.x * m_integerPrecision, v0CoordPos.y * m_integerPrecision, 0.f);
80 const Vec3f v1(v1CoordPos.x * m_integerPrecision, v1CoordPos.y * m_integerPrecision, 0.f);
81 const Vec3f v2(v2CoordPos.x * m_integerPrecision, v2CoordPos.y * m_integerPrecision, 0.f);
84 ClosestPoint::OnTriangleVsDiskCast2d(v0, v1, v2, m_startCenter, m_radius, m_normalizedDir2d, m_dist, unused, cost);
91 Vec2f m_normalizedDir2d;
95 OrientedBox2d m_orientedBox2d;
96 OrientedBox2d m_BBoxOfTheEndHalfDisk;
97 Vec3f m_centerOfTheEndHalfDisk;
#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