|
1 | 1 | #ifndef _CCOLLIDABLEOBBTREE |
2 | 2 | #define _CCOLLIDABLEOBBTREE |
3 | 3 |
|
4 | | -#include <Collision/CCollisionPrimitive.hpp> |
| 4 | +#include "Collision/CCollisionPrimitive.hpp" |
| 5 | +#include "Collision/CMaterialFilter.hpp" |
| 6 | +#include "Collision/CMaterialList.hpp" |
5 | 7 |
|
6 | | -class COBBTree; |
7 | | -class CCollidableOBBTree : public CCollisionPrimitive { |
| 8 | +#include "Kyoto/Math/CPlane.hpp" |
| 9 | + |
| 10 | +#include "WorldFormat/CMetroidAreaCollider.hpp" |
| 11 | +#include "WorldFormat/COBBTree.hpp" |
| 12 | + |
| 13 | +class CCollisionInfo; |
| 14 | +class CCollisionInfoList; |
| 15 | +class CMRay; |
| 16 | +class COBBox; |
| 17 | +class CSphere; |
| 18 | + |
| 19 | +class CRayCastInfo { |
| 20 | + const CMRay& x0_ray; |
| 21 | + const CMaterialFilter& x4_filter; |
| 22 | + float x8_mag; |
| 23 | + CPlane xc_plane; |
| 24 | + CMaterialList x20_material; |
8 | 25 |
|
9 | 26 | public: |
10 | | - CCollidableOBBTree(const COBBTree& tree, const CMaterialList& list); |
| 27 | + CRayCastInfo(const CMRay& ray, const CMaterialFilter& filter, float mag) |
| 28 | + : x0_ray(ray) |
| 29 | + , x4_filter(filter) |
| 30 | + , x8_mag(mag) |
| 31 | + , xc_plane(CVector3f::Zero(), CUnitVector3f(CVector3f(0.f, 0.f, 1.f), CUnitVector3f::kN_Yes)) |
| 32 | + , x20_material() {} |
| 33 | + |
| 34 | + const CMRay& GetRay() const { return x0_ray; } |
| 35 | + const CMaterialFilter& GetMaterialFilter() const { return x4_filter; } |
| 36 | + float GetMagnitude() const { return x8_mag; } |
| 37 | + float& Magnitude() { return x8_mag; } |
| 38 | + const CPlane& GetPlane() const { return xc_plane; } |
| 39 | + CPlane& Plane() { return xc_plane; } |
| 40 | + const CMaterialList& GetMaterial() const { return x20_material; } |
| 41 | + CMaterialList& Material() { return x20_material; } |
| 42 | +}; |
| 43 | + |
| 44 | +class CCollidableOBBTree : public CCollisionPrimitive { |
| 45 | +public: |
| 46 | + CCollidableOBBTree(COBBTree* tree, const CMaterialList& list); |
| 47 | + ~CCollidableOBBTree() override; |
11 | 48 |
|
12 | 49 | uint GetTableIndex() const override; |
13 | 50 | CAABox CalculateAABox(const CTransform4f& xf) const override; |
14 | | - const CAABox CalculateLocalAABox() const override; |
| 51 | + CAABox CalculateLocalAABox() const override; |
15 | 52 | FourCC GetPrimType() const override; |
16 | | - CRayCastResult CastRayInternal(const CInternalRayCastStructure& intRayCast) const override; |
| 53 | + CRayCastResult CastRayInternal(const CInternalRayCastStructure& rayCast) const override; |
| 54 | + |
| 55 | + const COBBTree& GetOBBTree() const { return *x10_tree; } |
| 56 | + |
| 57 | + bool AABoxCollision(const COBBTree::CNode& node, const CTransform4f& xf, const CAABox& aabb, |
| 58 | + const COBBox& obb, const CMaterialList& material, |
| 59 | + const CMaterialFilter& filter, const CPlane* planes, |
| 60 | + CCollisionInfoList& infoList) const; |
| 61 | + bool AABoxCollideWithLeaf(const COBBTree::CLeafData& leaf, const CTransform4f& xf, |
| 62 | + const CAABox& aabb, const CMaterialList& material, |
| 63 | + const CMaterialFilter& filter, const CPlane* planes, |
| 64 | + CCollisionInfoList& infoList) const; |
| 65 | + bool SphereCollision(const COBBTree::CNode& node, const CTransform4f& xf, |
| 66 | + const CSphere& sphere, const COBBox& obb, const CMaterialList& material, |
| 67 | + const CMaterialFilter& filter, CCollisionInfoList& infoList) const; |
| 68 | + bool SphereCollideWithLeaf(const COBBTree::CLeafData& leaf, const CTransform4f& xf, |
| 69 | + const CSphere& sphere, const CMaterialList& material, |
| 70 | + const CMaterialFilter& filter, CCollisionInfoList& infoList) const; |
| 71 | + bool AABoxCollisionBoolean(const COBBTree::CNode& node, const CTransform4f& xf, |
| 72 | + const CAABox& aabb, const COBBox& obb, |
| 73 | + const CMaterialFilter& filter) const; |
| 74 | + bool SphereCollisionBoolean(const COBBTree::CNode& node, const CTransform4f& xf, |
| 75 | + const CSphere& sphere, const COBBox& obb, |
| 76 | + const CMaterialFilter& filter) const; |
| 77 | + bool AABoxCollisionMoving(const COBBTree::CNode& node, const CTransform4f& xf, |
| 78 | + const CAABox& aabb, const COBBox& obb, |
| 79 | + const CMaterialList& material, const CMaterialFilter& filter, |
| 80 | + const CMetroidAreaCollider::CMovingAABoxComponents& components, |
| 81 | + const CVector3f& dir, double& dOut, CCollisionInfo& info) const; |
| 82 | + bool AABoxCollideWithLeafMoving( |
| 83 | + const COBBTree::CLeafData& leaf, const CTransform4f& xf, const CAABox& aabb, |
| 84 | + const CMaterialList& material, const CMaterialFilter& filter, |
| 85 | + const CMetroidAreaCollider::CMovingAABoxComponents& components, const CVector3f& dir, |
| 86 | + double& dOut, CCollisionInfo& info) const; |
| 87 | + bool SphereCollisionMoving(const COBBTree::CNode& node, const CTransform4f& xf, |
| 88 | + const CSphere& sphere, const COBBox& obb, |
| 89 | + const CMaterialList& material, const CMaterialFilter& filter, |
| 90 | + const CVector3f& dir, double& dOut, CCollisionInfo& info) const; |
| 91 | + bool SphereCollideWithLeafMoving(const COBBTree::CLeafData& leaf, const CTransform4f& xf, |
| 92 | + const CSphere& sphere, const CMaterialList& material, |
| 93 | + const CMaterialFilter& filter, const CVector3f& dir, |
| 94 | + double& dOut, CCollisionInfo& info) const; |
| 95 | + |
| 96 | + CRayCastResult LineIntersectsTree(const CMRay& ray, const CMaterialFilter& filter, float maxTime, |
| 97 | + const CTransform4f& xf) const; |
| 98 | + bool LineIntersectsOBBTree(const COBBTree::CNode* node, CRayCastInfo& info) const; |
| 99 | + bool LineIntersectsOBBTree(const COBBTree::CNode* n0, const COBBTree::CNode* n1, |
| 100 | + CRayCastInfo& info) const; |
| 101 | + bool LineIntersectsLeaf(const COBBTree::CLeafData& leaf, CRayCastInfo& info) const; |
| 102 | + |
| 103 | + static void SetStaticTableIndex(uint idx) { sTableIndex = idx; } |
| 104 | + |
| 105 | +private: |
| 106 | + COBBTree* x10_tree; |
| 107 | + uint x14_tries; |
| 108 | + uint x18_misses; |
| 109 | + uint x1c_hits; |
| 110 | + |
| 111 | + static uint sTableIndex; |
17 | 112 | }; |
| 113 | +CHECK_SIZEOF(CCollidableOBBTree, 0x20) |
18 | 114 |
|
19 | 115 | #endif // _CCOLLIDABLEOBBTREE |
0 commit comments