metaforce/Runtime/World/CPathFindRegion.hpp

112 lines
3.9 KiB
C++
Raw Normal View History

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
{
u32 x0_node;
u32 x4_region;
2018-02-14 07:51:18 +00:00
float x8_2dWidth;
float xc_oo2dWidth;
public:
CPFLink(CMemoryInStream& in);
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; }
u32 GetIndex() const { return x24_regionIdx; }
2018-02-14 07:51:18 +00:00
float GetHeight() const { return x14_height; }
void GetPathLink() const {}
u32 GetNumLinks() const { return x8_numLinks; }
u32 GetFlags() const { return x10_flags; }
const CPFLink* GetLink(u32 i) const { return xc_startLink + i; }
2016-08-10 16:05:14 +00:00
void SetCentroid(const zeus::CVector3f&);
2018-02-14 07:51:18 +00:00
const zeus::CVector3f& GetCentroid() const { return x28_centroid; }
void Fixup(CPFArea& area, u32& maxRegionNodes);
2016-08-10 16:05:14 +00:00
bool IsPointInside(const zeus::CVector3f&);
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);
2016-08-10 16:05:14 +00:00
void SetLinkTo(s32);
void DropToGround(zeus::CVector3f&) const;
void GetLinkMidPoint(const CPFLink&);
zeus::CVector3f FitThroughLink2d(const zeus::CVector3f&, const CPFLink&, const zeus::CVector3f&, float) const;
zeus::CVector3f FitThroughLink3d(const zeus::CVector3f&, const CPFLink&, float, const zeus::CVector3f&, float, float) 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;
s32 x10_cookie = -1;
2016-08-10 16:05:14 +00:00
zeus::CVector3f x14_;
s32 x20_ = 0;
CPFRegion* x24_openLess = nullptr;
CPFRegion* x28_openMore = nullptr;
s32 x2c_pathLink = 0;
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; }
2016-08-10 16:05:14 +00:00
void GetCost();
s32 GetPathLink() const { return x2c_pathLink; }
void SetPathLink(s32 l) { x2c_pathLink = l; }
2016-08-10 16:05:14 +00:00
void GetParent() const;
void Setup(CPFRegion*, float, float);
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; }
void SetCookie(s32 c) { x10_cookie = c; }
s32 GetCookie() const { return x10_cookie; }
2016-08-10 16:05:14 +00:00
};
}
#endif // __URDE_CPATHFINDREGION_HPP__