2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2018-02-14 07:51:18 +00:00
|
|
|
|
2019-09-22 21:52:05 +00:00
|
|
|
#include <optional>
|
|
|
|
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
#include "Runtime/rstl.hpp"
|
|
|
|
#include "Runtime/Graphics/CLineRenderer.hpp"
|
|
|
|
#include "Runtime/World/CPathFindArea.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CVector3f.hpp>
|
2018-02-14 07:51:18 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2018-12-15 06:29:41 +00:00
|
|
|
class CPathFindSearch;
|
|
|
|
|
|
|
|
class CPathFindVisualizer {
|
|
|
|
CLineRenderer m_spline = {CLineRenderer::EPrimitiveMode::LineStrip, 16, {}, true};
|
2020-03-26 07:30:54 +00:00
|
|
|
|
2018-12-15 06:29:41 +00:00
|
|
|
public:
|
|
|
|
void Draw(const CPathFindSearch& path);
|
|
|
|
};
|
2018-02-14 07:51:18 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CPathFindSearch {
|
2018-03-01 06:17:16 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EResult { Success, InvalidArea, NoSourcePoint, NoDestPoint, NoPath };
|
|
|
|
|
2018-03-01 06:17:16 +00:00
|
|
|
private:
|
2018-12-08 05:30:43 +00:00
|
|
|
CPFArea* x0_area;
|
|
|
|
rstl::reserved_vector<zeus::CVector3f, 16> x4_waypoints;
|
|
|
|
u32 xc8_curWaypoint = 0;
|
2020-04-13 20:29:09 +00:00
|
|
|
EResult xcc_result{};
|
2018-12-08 05:30:43 +00:00
|
|
|
float xd0_chHeight;
|
|
|
|
float xd4_chRadius;
|
|
|
|
float xd8_padding = 10.f;
|
|
|
|
u32 xdc_flags; // 0x2: flyer, 0x4: path-always-exists (swimmers)
|
|
|
|
u32 xe0_indexMask;
|
2020-04-10 01:49:59 +00:00
|
|
|
std::optional<CPathFindVisualizer> m_viz;
|
2018-12-08 05:30:43 +00:00
|
|
|
bool Search(rstl::reserved_vector<CPFRegion*, 4>& regs1, const zeus::CVector3f& p1,
|
|
|
|
rstl::reserved_vector<CPFRegion*, 4>& regs2, const zeus::CVector3f& p2);
|
|
|
|
void GetSplinePoint(zeus::CVector3f& pOut, const zeus::CVector3f& p1, u32 wpIdx) const;
|
|
|
|
void GetSplinePointWithLookahead(zeus::CVector3f& pOut, const zeus::CVector3f& p1, u32 wpIdx, float lookahead) const;
|
|
|
|
|
2018-02-14 07:51:18 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CPathFindSearch(CPFArea* area, u32 flags, u32 index, float chRadius, float chHeight);
|
|
|
|
EResult Search(const zeus::CVector3f& p1, const zeus::CVector3f& p2);
|
|
|
|
EResult FindClosestReachablePoint(const zeus::CVector3f& p1, zeus::CVector3f& p2) const;
|
|
|
|
EResult PathExists(const zeus::CVector3f& p1, const zeus::CVector3f& p2) const;
|
|
|
|
EResult OnPath(const zeus::CVector3f& p1) const;
|
|
|
|
EResult GetResult() const { return xcc_result; }
|
|
|
|
u32 GetCurrentWaypoint() const { return xc8_curWaypoint; }
|
|
|
|
void SetCurrentWaypoint(u32 wp) { xc8_curWaypoint = wp; }
|
|
|
|
const rstl::reserved_vector<zeus::CVector3f, 16>& GetWaypoints() const { return x4_waypoints; }
|
2019-01-16 04:22:44 +00:00
|
|
|
bool IsOver() const { return GetCurrentWaypoint() >= x4_waypoints.size() - 1; }
|
2018-12-08 05:30:43 +00:00
|
|
|
bool IsShagged() const { return GetResult() != EResult::Success; }
|
|
|
|
bool SegmentOver(const zeus::CVector3f& p1) const;
|
|
|
|
void GetSplinePoint(zeus::CVector3f& pOut, const zeus::CVector3f& p1) const;
|
|
|
|
void GetSplinePointWithLookahead(zeus::CVector3f& pOut, const zeus::CVector3f& p1, float lookahead) const;
|
|
|
|
void SetArea(CPFArea* area) { x0_area = area; }
|
2018-12-13 07:39:16 +00:00
|
|
|
float GetCharacterHeight() const { return xd0_chHeight; }
|
|
|
|
void SetCharacterHeight(float h) { xd0_chHeight = h; }
|
2020-03-26 07:30:54 +00:00
|
|
|
float GetCharacterRadius() const { return xd4_chRadius; }
|
|
|
|
void SetCharacterRadius(float r) { xd4_chRadius = r; }
|
2020-02-07 21:27:53 +00:00
|
|
|
void SetPadding(float padding) { xd8_padding = padding; }
|
2018-12-13 07:39:16 +00:00
|
|
|
float RemainingPathDistance(const zeus::CVector3f& pos) const;
|
2020-04-10 01:49:59 +00:00
|
|
|
void DebugDraw();
|
2018-02-14 07:51:18 +00:00
|
|
|
};
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|