9 #ifndef Navigation_PolylineCastIntersector_H
10 #define Navigation_PolylineCastIntersector_H
19 class DatabaseGenMetrics;
20 class PolylineCastIntersector
25 enum VolumeType { Quad, TriangleAroundRight, TriangleAroundLeft };
30 BorderEdge() : m_startAxis_f(0.f), m_endAxis_f(0.f), m_startOrdinate_f(0.f), m_endOrdinate_f(0.f) {}
39 NavHalfEdgeRawPtr m_edgeRawPtr;
42 PolylineCastIntersector();
43 ~PolylineCastIntersector();
45 void InitTrapezoid(
const Vec3f& pathEdgeStartPos3f,
const Vec3f& pathEdgeEndPos3f,
const Vec3f& onStartLeft,
const Vec3f& onEndLeft,
46 const Vec3f& onStartRight,
const Vec3f& onEndRight,
const DatabaseGenMetrics& genMetrics);
48 void InitTriangleAroundRight(
const Vec3f& pathEdgeStartPos3f,
const Vec3f& pathEdgeEndPos3f,
const Vec3f& onStartLeft,
const Vec3f& onEndLeft,
49 const Vec3f& onRight,
const DatabaseGenMetrics& genMetrics);
51 void InitTriangleAroundLeft(
const Vec3f& pathEdgeStartPos3f,
const Vec3f& pathEdgeEndPos3f,
const Vec3f& onLeft,
52 const Vec3f& onStartRight,
const Vec3f& onEndRight,
const DatabaseGenMetrics& genMetrics);
54 bool IsEdgeVisible(
const CoordPos64& ,
const CoordPos64& ,
const NavHalfEdgeRawPtr& edgeRawPtr,
bool edgeIsCrossable);
60 void Init(VolumeType volumeType,
KyFloat32 integerPrecision,
const Vec3f& pathEdgeStartPos3f,
const Vec3f& pathEdgeEndPos3f,
61 const Vec3f& onStartLeft,
const Vec3f& onEndLeft,
const Vec3f& onStartRight,
const Vec3f& onEndRight);
63 bool ProcessCrossableEdge(
KyFloat32 firstAxis,
KyFloat32 lastAxis,
const Vec3f& firstPos,
const Vec3f& lastPos);
64 bool ProcessNonCrossableEdge(
const Vec3f& firstPos,
const Vec3f& lastPos,
KyFloat32 firstAxis,
KyFloat32 lastAxis,
67 bool BoundEdgeToBorderEdgeAxis(
const Vec3f& firstPos,
const Vec3f& lastPos,
KyFloat32& firstAxis,
KyFloat32& lastAxis,
KyFloat32 borderEdgeAxisStart,
68 KyFloat32 borderEdgeAxisEnd, Vec3f& startPosForThisBorder, Vec3f& endPosForThisBorder);
70 bool SnapExtremityIfNeeded(
const Vec3f& firstPos,
const Vec3f& lastPos,
bool onLeft, BorderEdge* currentBorderEdge,
71 Vec3f& startPosForThisBorder, Vec3f& endPosForThisBorder,
KyFloat32& snappedFirstAxis,
KyFloat32& snappedLastAxis,
72 KyFloat32& ordinateForStartPosForThisBorder,
KyFloat32& ordinateForEndPosForThisBorder);
74 bool SnappedEdgeStartToBorderStartAxis(
const Vec3f& firstPos,
const Vec3f& lastPos, BorderEdge* currentBorderEdge,
bool onLeft, Vec3f& startPosForThisBorder,
75 KyFloat32& ordinateForStartPosForThisBorder);
76 bool SnappedEdgeEndToBorderEndAxis(
const Vec3f& firstPos,
const Vec3f& lastPos, BorderEdge* currentBorderEdge,
bool onLeft,
77 Vec3f& endPosForThisBorder,
KyFloat32& ordinateForEndPosForThisBorder);
79 bool IsVisibleForBorderLeft(
const Vec3f& startPosForThisBorder,
const Vec3f& endPosForThisBorder, PolylineCastIntersector::BorderEdge* borderEdgeOnLeft);
80 bool IsVisibleForBorderRight(
const Vec3f& startPosForThisBorder,
const Vec3f& endPosForThisBorder, PolylineCastIntersector::BorderEdge* borderEdgeOnRight);
82 bool DoesEdgeIntersectVolume(
const Vec3f& startEdgePos,
const Vec3f& endEdgePos);
85 KyFloat32 GetOrdinateValue(
const Vec3f& pos) {
return CrossProduct_z(m_pathEdgeEndPos3f-m_pathEdgeStartPos3f, pos-m_pathEdgeStartPos3f); }
87 bool GetPointAtAxisOnEdgeRatio(
const Vec3f& startEdgePos,
const Vec3f& endEdgePos,
KyFloat32 wantedAxis,
KyFloat32& ratio);
88 bool GetPointAtAxisOnEdge(
const Vec3f& startEdgePos,
const Vec3f& endEdgePos,
KyFloat32 wantedAxis, Vec3f& pos);
90 bool BoundEdgeToTrapezoidEdge(Vec3f& startEdgePos, Vec3f& endEdgePos,
const Vec3f& trapezoidEdgeStart,
const Vec3f& trapezoidEdgeEnd);
91 bool BoundEdgeToTrapezoidLimit(Vec3f& startEdgePos, Vec3f& endEdgePos);
94 Vec3f m_pathEdgeStartPos3f;
95 Vec3f m_pathEdgeEndPos3f;
97 Vec3f m_startLeftPos3f;
98 Vec3f m_startRightPos3f;
100 Vec3f m_endLeftPos3f;
101 Vec3f m_endRightPos3f;
104 Vec3f m_edgeExtentForTest;
120 SharedPoolList<BorderEdge> m_borderEdgesOnLeft;
121 SharedPoolList<BorderEdge> m_borderEdgesOnRight;
122 SharedPoolList<BorderEdge>::NodePool m_borderEdgePool;
127 #endif //Navigation_PolylineCastIntersector_H
KyFloat32 CrossProduct_z(const Vec3f &v1, const Vec3f &v2)
Returns the Z component of the cross product of v1 and v2.
Definition: vec3f.h:261
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