2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-04-17 22:38:05 +00:00
|
|
|
|
2016-04-27 00:26:02 +00:00
|
|
|
#include "Collision/CCollisionPrimitive.hpp"
|
|
|
|
#include "COBBTree.hpp"
|
2017-07-03 03:34:19 +00:00
|
|
|
#include "zeus/COBBox.hpp"
|
|
|
|
#include "CMetroidAreaCollider.hpp"
|
2016-04-27 00:26:02 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
|
|
|
class CRayCastInfo {
|
|
|
|
const zeus::CMRay& x0_ray;
|
|
|
|
const CMaterialFilter& x4_filter;
|
|
|
|
float x8_mag;
|
2019-02-24 07:15:54 +00:00
|
|
|
zeus::CPlane xc_plane = {zeus::skUp, 0.f};
|
2018-12-08 05:30:43 +00:00
|
|
|
CMaterialList x20_material;
|
|
|
|
|
2017-07-02 05:40:12 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CRayCastInfo(const zeus::CMRay& ray, const CMaterialFilter& filter, float mag)
|
|
|
|
: x0_ray(ray), x4_filter(filter), x8_mag(mag) {}
|
|
|
|
const zeus::CMRay& GetRay() const { return x0_ray; }
|
|
|
|
const CMaterialFilter& GetMaterialFilter() const { return x4_filter; }
|
|
|
|
float GetMagnitude() const { return x8_mag; }
|
|
|
|
float& Magnitude() { return x8_mag; }
|
|
|
|
const zeus::CPlane& GetPlane() const { return xc_plane; }
|
|
|
|
zeus::CPlane& Plane() { return xc_plane; }
|
|
|
|
const CMaterialList& GetMaterial() const { return x20_material; }
|
|
|
|
CMaterialList& Material() { return x20_material; }
|
2017-07-02 05:40:12 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CCollidableOBBTree : public CCollisionPrimitive {
|
|
|
|
friend class CCollidableOBBTreeGroup;
|
|
|
|
COBBTree* x10_tree = nullptr;
|
|
|
|
u32 x14_tries = 0;
|
|
|
|
u32 x18_misses = 0;
|
|
|
|
u32 x1c_hits = 0;
|
|
|
|
static u32 sTableIndex;
|
|
|
|
bool LineIntersectsLeaf(const COBBTree::CLeafData& leaf, CRayCastInfo& info) const;
|
|
|
|
bool LineIntersectsOBBTree(const COBBTree::CNode& n0, const COBBTree::CNode& n1, CRayCastInfo& info) const;
|
|
|
|
bool LineIntersectsOBBTree(const COBBTree::CNode& node, CRayCastInfo& info) const;
|
|
|
|
CRayCastResult LineIntersectsTree(const zeus::CMRay& ray, const CMaterialFilter& filter, float maxTime,
|
|
|
|
const zeus::CTransform& xf) const;
|
|
|
|
static zeus::CPlane TransformPlane(const zeus::CPlane& pl, const zeus::CTransform& xf);
|
|
|
|
bool SphereCollideWithLeafMoving(const COBBTree::CLeafData& leaf, const zeus::CTransform& xf,
|
|
|
|
const zeus::CSphere& sphere, const CMaterialList& material,
|
|
|
|
const CMaterialFilter& filter, const zeus::CVector3f& dir, double& dOut,
|
|
|
|
CCollisionInfo& info) const;
|
|
|
|
bool SphereCollisionMoving(const COBBTree::CNode& node, const zeus::CTransform& xf, const zeus::CSphere& sphere,
|
|
|
|
const zeus::COBBox& obb, const CMaterialList& material, const CMaterialFilter& filter,
|
|
|
|
const zeus::CVector3f& dir, double& dOut, CCollisionInfo& info) const;
|
|
|
|
bool AABoxCollideWithLeafMoving(const COBBTree::CLeafData& leaf, const zeus::CTransform& xf, const zeus::CAABox& aabb,
|
|
|
|
const CMaterialList& material, const CMaterialFilter& filter,
|
|
|
|
const CMovingAABoxComponents& components, const zeus::CVector3f& dir, double& dOut,
|
|
|
|
CCollisionInfo& info) const;
|
|
|
|
bool AABoxCollisionMoving(const COBBTree::CNode& node, const zeus::CTransform& xf, const zeus::CAABox& aabb,
|
|
|
|
const zeus::COBBox& obb, const CMaterialList& material, const CMaterialFilter& filter,
|
|
|
|
const CMovingAABoxComponents& components, const zeus::CVector3f& dir, double& dOut,
|
|
|
|
CCollisionInfo& info) const;
|
|
|
|
bool SphereCollisionBoolean(const COBBTree::CNode& node, const zeus::CTransform& xf, const zeus::CSphere& sphere,
|
|
|
|
const zeus::COBBox& obb, const CMaterialFilter& filter) const;
|
|
|
|
bool AABoxCollisionBoolean(const COBBTree::CNode& node, const zeus::CTransform& xf, const zeus::CAABox& aabb,
|
|
|
|
const zeus::COBBox& obb, const CMaterialFilter& filter) const;
|
|
|
|
bool SphereCollideWithLeaf(const COBBTree::CLeafData& leaf, const zeus::CTransform& xf, const zeus::CSphere& sphere,
|
|
|
|
const CMaterialList& material, const CMaterialFilter& filter,
|
|
|
|
CCollisionInfoList& infoList) const;
|
|
|
|
bool SphereCollision(const COBBTree::CNode& node, const zeus::CTransform& xf, const zeus::CSphere& sphere,
|
|
|
|
const zeus::COBBox& obb, const CMaterialList& material, const CMaterialFilter& filter,
|
|
|
|
CCollisionInfoList& infoList) const;
|
|
|
|
bool AABoxCollideWithLeaf(const COBBTree::CLeafData& leaf, const zeus::CTransform& xf, const zeus::CAABox& aabb,
|
|
|
|
const CMaterialList& material, const CMaterialFilter& filter, const zeus::CPlane* planes,
|
|
|
|
CCollisionInfoList& infoList) const;
|
|
|
|
bool AABoxCollision(const COBBTree::CNode& node, const zeus::CTransform& xf, const zeus::CAABox& aabb,
|
|
|
|
const zeus::COBBox& obb, const CMaterialList& material, const CMaterialFilter& filter,
|
|
|
|
const zeus::CPlane* planes, CCollisionInfoList& infoList) const;
|
|
|
|
|
2016-04-27 00:26:02 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CCollidableOBBTree(const COBBTree* tree, const CMaterialList& material);
|
2019-08-09 19:46:49 +00:00
|
|
|
~CCollidableOBBTree() override = default;
|
2018-12-08 05:30:43 +00:00
|
|
|
void ResetTestStats() const;
|
|
|
|
void ResetTestStatsRecurse(const COBBTree::CNode&) const;
|
2019-08-09 19:46:49 +00:00
|
|
|
u32 GetTableIndex() const override { return sTableIndex; }
|
|
|
|
zeus::CAABox CalculateAABox(const zeus::CTransform&) const override;
|
|
|
|
zeus::CAABox CalculateLocalAABox() const override;
|
|
|
|
FourCC GetPrimType() const override;
|
|
|
|
CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const override;
|
2016-04-17 22:38:05 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|