2016-08-10 16:05:14 +00:00
|
|
|
#ifndef __URDE_CPATHFINDREGION_HPP__
|
|
|
|
#define __URDE_CPATHFINDREGION_HPP__
|
|
|
|
|
|
|
|
#include "RetroTypes.hpp"
|
|
|
|
#include "zeus/CAABox.hpp"
|
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
class CPFArea;
|
|
|
|
class CPFLink;
|
|
|
|
class CPFRegionData;
|
2018-02-14 07:51:18 +00:00
|
|
|
|
|
|
|
class CPFNode
|
|
|
|
{
|
|
|
|
zeus::CVector3f x0_position;
|
|
|
|
zeus::CVector3f xc_normal;
|
|
|
|
public:
|
|
|
|
CPFNode(CMemoryInStream& in);
|
|
|
|
const zeus::CVector3f& GetPos() const { return x0_position; }
|
|
|
|
const zeus::CVector3f& GetNormal() const { return xc_normal; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class CPFLink
|
|
|
|
{
|
2018-02-15 04:37:21 +00:00
|
|
|
u32 x0_node;
|
|
|
|
u32 x4_region;
|
2018-02-14 07:51:18 +00:00
|
|
|
float x8_2dWidth;
|
|
|
|
float xc_oo2dWidth;
|
|
|
|
public:
|
|
|
|
CPFLink(CMemoryInStream& in);
|
2018-02-15 04:37:21 +00:00
|
|
|
u32 GetNode() const { return x0_node; }
|
|
|
|
u32 GetRegion() const { return x4_region; }
|
2018-02-14 07:51:18 +00:00
|
|
|
float Get2dWidth() const { return x8_2dWidth; }
|
|
|
|
float GetOO2dWidth() const { return xc_oo2dWidth; }
|
|
|
|
};
|
|
|
|
|
2016-08-10 16:05:14 +00:00
|
|
|
class CPFRegion
|
|
|
|
{
|
2018-02-14 07:51:18 +00:00
|
|
|
u32 x0_numNodes = 0;
|
|
|
|
CPFNode* x4_startNode = nullptr;
|
|
|
|
u32 x8_numLinks = 0;
|
|
|
|
CPFLink* xc_startLink = nullptr;
|
|
|
|
u32 x10_flags = 0;
|
|
|
|
float x14_height = 0.f;
|
|
|
|
zeus::CVector3f x18_normal;
|
|
|
|
u32 x24_regionIdx = 0;
|
|
|
|
zeus::CVector3f x28_centroid;
|
|
|
|
zeus::CAABox x34_aabb;
|
|
|
|
CPFRegionData* x4c_regionData;
|
2016-08-10 16:05:14 +00:00
|
|
|
public:
|
|
|
|
CPFRegion() = default;
|
2018-02-14 07:51:18 +00:00
|
|
|
CPFRegion(CMemoryInStream& in);
|
|
|
|
void SetData(CPFRegionData* data) { x4c_regionData = data; }
|
|
|
|
CPFRegionData* Data() const { return x4c_regionData; }
|
2018-02-15 04:37:21 +00:00
|
|
|
u32 GetIndex() const { return x24_regionIdx; }
|
2018-02-14 07:51:18 +00:00
|
|
|
float GetHeight() const { return x14_height; }
|
2018-03-03 05:49:13 +00:00
|
|
|
const CPFLink* GetPathLink() const;
|
2018-02-14 07:51:18 +00:00
|
|
|
u32 GetNumLinks() const { return x8_numLinks; }
|
|
|
|
u32 GetFlags() const { return x10_flags; }
|
|
|
|
const CPFLink* GetLink(u32 i) const { return xc_startLink + i; }
|
2018-03-03 05:49:13 +00:00
|
|
|
void SetCentroid(const zeus::CVector3f& c) { x28_centroid = c; }
|
2018-02-14 07:51:18 +00:00
|
|
|
const zeus::CVector3f& GetCentroid() const { return x28_centroid; }
|
|
|
|
void Fixup(CPFArea& area, u32& maxRegionNodes);
|
2018-03-03 05:49:13 +00:00
|
|
|
bool IsPointInside(const zeus::CVector3f& point) const;
|
2018-02-14 07:51:18 +00:00
|
|
|
const zeus::CVector3f& GetNormal() const { return x18_normal; }
|
|
|
|
u32 GetNumNodes() const { return x0_numNodes; }
|
|
|
|
const CPFNode* GetNode(u32 i) const { return x4_startNode + i; }
|
2018-03-01 06:17:16 +00:00
|
|
|
float PointHeight(const zeus::CVector3f& point) const;
|
|
|
|
bool FindClosestPointOnPolygon(const std::vector<zeus::CVector3f>&, const zeus::CVector3f&,
|
2018-02-14 07:51:18 +00:00
|
|
|
const zeus::CVector3f&, bool);
|
2018-03-01 06:17:16 +00:00
|
|
|
bool FindBestPoint(std::vector<zeus::CVector3f>& polyPoints, const zeus::CVector3f& point, u32 flags, float paddingSq);
|
2018-03-03 05:49:13 +00:00
|
|
|
void SetLinkTo(s32 idx);
|
|
|
|
void DropToGround(zeus::CVector3f& point) const;
|
|
|
|
zeus::CVector3f GetLinkMidPoint(const CPFLink& link) const;
|
|
|
|
zeus::CVector3f FitThroughLink2d(const zeus::CVector3f& p1, const CPFLink& link,
|
|
|
|
const zeus::CVector3f& p2, float chRadius) const;
|
|
|
|
zeus::CVector3f FitThroughLink3d(const zeus::CVector3f& p1, const CPFLink& link,
|
|
|
|
float regionHeight, const zeus::CVector3f& p2,
|
|
|
|
float chRadius, float chHalfHeight) const;
|
2018-03-01 06:17:16 +00:00
|
|
|
bool IsPointInsidePaddedAABox(const zeus::CVector3f& point, float padding) const;
|
2016-08-10 16:05:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CPFRegionData
|
|
|
|
{
|
2018-03-01 06:17:16 +00:00
|
|
|
float x0_bestPointDistSq = 0.f;
|
|
|
|
zeus::CVector3f x4_bestPoint;
|
2018-02-15 04:37:21 +00:00
|
|
|
s32 x10_cookie = -1;
|
2018-03-03 05:49:13 +00:00
|
|
|
float x14_cost = 0.f;
|
|
|
|
float x18_g = 0.f;
|
|
|
|
float x1c_h = 0.f;
|
|
|
|
CPFRegion* x20_parent = nullptr;
|
2016-08-10 16:05:14 +00:00
|
|
|
CPFRegion* x24_openLess = nullptr;
|
|
|
|
CPFRegion* x28_openMore = nullptr;
|
2018-02-15 04:37:21 +00:00
|
|
|
s32 x2c_pathLink = 0;
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2016-08-10 16:05:14 +00:00
|
|
|
public:
|
|
|
|
CPFRegionData() = default;
|
2018-02-14 07:51:18 +00:00
|
|
|
void SetOpenLess(CPFRegion* r) { x24_openLess = r; }
|
|
|
|
void SetOpenMore(CPFRegion* r) { x28_openMore = r; }
|
|
|
|
CPFRegion* GetOpenLess() const { return x24_openLess; }
|
|
|
|
CPFRegion* GetOpenMore() const { return x28_openMore; }
|
2018-03-03 05:49:13 +00:00
|
|
|
float GetCost() const { return x14_cost; }
|
|
|
|
float GetG() const { return x18_g; }
|
2018-02-15 04:37:21 +00:00
|
|
|
s32 GetPathLink() const { return x2c_pathLink; }
|
|
|
|
void SetPathLink(s32 l) { x2c_pathLink = l; }
|
2018-03-03 05:49:13 +00:00
|
|
|
CPFRegion* GetParent() const { return x20_parent; }
|
2018-03-01 06:17:16 +00:00
|
|
|
void SetBestPoint(const zeus::CVector3f& bestPoint) { x4_bestPoint = bestPoint; }
|
|
|
|
const zeus::CVector3f& GetBestPoint() const { return x4_bestPoint; }
|
|
|
|
void SetBestPointDistanceSquared(float distSq) { x0_bestPointDistSq = distSq; }
|
|
|
|
float GetBestPointDistanceSquared() const { return x0_bestPointDistSq; }
|
2018-02-15 04:37:21 +00:00
|
|
|
void SetCookie(s32 c) { x10_cookie = c; }
|
|
|
|
s32 GetCookie() const { return x10_cookie; }
|
2018-03-03 05:49:13 +00:00
|
|
|
|
|
|
|
void Setup(CPFRegion* parent, float g, float h)
|
|
|
|
{
|
|
|
|
x20_parent = parent;
|
|
|
|
x18_g = g;
|
|
|
|
x1c_h = h;
|
|
|
|
x14_cost = x18_g + x1c_h;
|
|
|
|
}
|
|
|
|
void Setup(CPFRegion* parent, float g)
|
|
|
|
{
|
|
|
|
x20_parent = parent;
|
|
|
|
x18_g = g;
|
|
|
|
x14_cost = x18_g + x1c_h;
|
|
|
|
}
|
2016-08-10 16:05:14 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __URDE_CPATHFINDREGION_HPP__
|