12 #ifndef Navigation_CrossedSectionCapsuleIntersector_H
13 #define Navigation_CrossedSectionCapsuleIntersector_H
27 class CrossedSectionCapsuleIntersector
32 CrossedSectionCapsuleIntersector(const BaseDiskCastQuery& query,
KyFloat32 distOnRight,
KyFloat32 distOnLeft) :
33 m_integerPrecision(query.m_database->GetDatabaseGenMetrics().m_integerPrecision), m_startCenter(query.GetStartPos()), m_normalizedDir2d(query.GetNormalizedDir2d()),
34 m_dist(query.GetMaxDist()), m_radius(query.GetRadius())
36 const Vec2f normalizedDir_ortho(m_normalizedDir2d.PerpCCW());
37 const Vec3f normalizedDir3D(m_normalizedDir2d.x, m_normalizedDir2d.y, 0.f);
38 const Vec3f normalizedDir3D_ortho(normalizedDir_ortho.x, normalizedDir_ortho.y, 0.f);
40 m_centerOfTheEndHalfDisk = m_startCenter + (normalizedDir3D * m_dist);
42 const Vec3f orientedBox2d_a(m_startCenter - (normalizedDir3D_ortho * distOnRight));
43 const Vec3f m_BBoxOfTheEndHalfDisk_a(m_centerOfTheEndHalfDisk - (normalizedDir3D_ortho * distOnRight));
45 m_orientedBox2d.Set(orientedBox2d_a, m_normalizedDir2d, m_dist, distOnRight + distOnLeft, 0.f);
46 m_BBoxOfTheEndHalfDisk.Set(m_BBoxOfTheEndHalfDisk_a, m_normalizedDir2d, m_radius, distOnRight + distOnLeft, 0.f);
49 CrossedSectionCapsuleIntersector(
const BaseDiskCanGoQuery& query,
KyFloat32 distOnRight,
KyFloat32 distOnLeft) :
50 m_integerPrecision(query.m_database->GetDatabaseGenMetrics().m_integerPrecision), m_startCenter(query.GetStartPos()), m_radius(query.GetRadius())
52 Vec3f dir(query.GetDestPos() - query.GetStartPos());
54 m_dist = dir.Normalize();
55 m_normalizedDir2d.Set(dir.x, dir.y);
57 const Vec2f normalizedDir_ortho(m_normalizedDir2d.PerpCCW());
58 const Vec3f normalizedDir3D(m_normalizedDir2d.x, m_normalizedDir2d.y, 0.f);
59 const Vec3f normalizedDir3D_ortho(normalizedDir_ortho.x, normalizedDir_ortho.y, 0.f);
61 m_centerOfTheEndHalfDisk = m_startCenter + (normalizedDir3D * m_dist);
63 const Vec3f orientedBox2d_a(m_startCenter - (normalizedDir3D_ortho * distOnRight));
64 const Vec3f m_BBoxOfTheEndHalfDisk_a(m_centerOfTheEndHalfDisk - (normalizedDir3D_ortho * distOnRight));
66 m_orientedBox2d.Set(orientedBox2d_a, m_normalizedDir2d, m_dist, distOnRight + distOnLeft, 0.f);
67 m_BBoxOfTheEndHalfDisk.Set(m_BBoxOfTheEndHalfDisk_a, m_normalizedDir2d, m_radius, distOnRight + distOnLeft, 0.f);
72 const Vec3f startEdgePos(startEdgeCoordPos.x * m_integerPrecision, startEdgeCoordPos.y * m_integerPrecision, 0.f);
73 const Vec3f endEdgePos(endEdgeCoordPos.x * m_integerPrecision, endEdgeCoordPos.y * m_integerPrecision, 0.f);
75 return Intersections::SegmentVsCrossSectionCapsule2d(startEdgePos, endEdgePos, m_orientedBox2d, m_centerOfTheEndHalfDisk, m_radius, m_BBoxOfTheEndHalfDisk);
78 void ComputeCollisionPosOnEdge(
const CoordPos64& startEdgeCoordPos,
const CoordPos64& endEdgeCoordPos, Vec3f& collisionPos,
KyFloat32& squareDistToCollisionPos)
80 const Vec3f startEdgePos(startEdgeCoordPos.x * m_integerPrecision, startEdgeCoordPos.y * m_integerPrecision, 0.f);
81 const Vec3f endEdgePos(endEdgeCoordPos.x * m_integerPrecision, endEdgeCoordPos.y * m_integerPrecision, 0.f);
83 ClosestPoint::OnSegmentVsDiskCast2d(startEdgePos, endEdgePos, m_startCenter, m_radius, m_normalizedDir2d, m_dist, collisionPos, squareDistToCollisionPos);
88 const Vec3f v0(v0CoordPos.x * m_integerPrecision, v0CoordPos.y * m_integerPrecision, 0.f);
89 const Vec3f v1(v1CoordPos.x * m_integerPrecision, v1CoordPos.y * m_integerPrecision, 0.f);
90 const Vec3f v2(v2CoordPos.x * m_integerPrecision, v2CoordPos.y * m_integerPrecision, 0.f);
93 ClosestPoint::OnTriangleVsDiskCast2d(v0, v1, v2, m_startCenter, m_radius, m_normalizedDir2d, m_dist, unused, cost);
100 Vec2f m_normalizedDir2d;
104 OrientedBox2d m_orientedBox2d;
105 OrientedBox2d m_BBoxOfTheEndHalfDisk;
106 Vec3f m_centerOfTheEndHalfDisk;
113 #endif //Navigation_CrossedSectionCapsuleIntersector_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