diff --git a/Runtime/Collision/CCollidableOBBTree.cpp b/Runtime/Collision/CCollidableOBBTree.cpp index 445b40785..5fa8a27fb 100644 --- a/Runtime/Collision/CCollidableOBBTree.cpp +++ b/Runtime/Collision/CCollidableOBBTree.cpp @@ -22,11 +22,12 @@ CRayCastResult CCollidableOBBTree::CastRayInternal(const CInternalRayCastStructu zeus::CAABox CCollidableOBBTree::CalculateAABox(const zeus::CTransform&) const { - + return x10_tree->CalculateLocalAABox(); } zeus::CAABox CCollidableOBBTree::CalculateLocalAABox() const { + } } diff --git a/Runtime/Collision/COBBTree.cpp b/Runtime/Collision/COBBTree.cpp index f0f34bc5d..d80a137f8 100644 --- a/Runtime/Collision/COBBTree.cpp +++ b/Runtime/Collision/COBBTree.cpp @@ -28,6 +28,18 @@ COBBTree::COBBTree(CInputStream& in) { } +zeus::CAABox COBBTree::CalculateLocalAABox() const +{ + return CalculateAABox(zeus::CTransform::Identity()); +} + +zeus::CAABox COBBTree::CalculateAABox(const zeus::CTransform& xf) const +{ + if (x88_root) + return x88_root->GetOBB().calculateAABox(xf); + return zeus::CAABox::skInvertedBox; +} + COBBTree::SIndexData::SIndexData(CInputStream& in) { u32 count = in.readUint32Big(); diff --git a/Runtime/Collision/COBBTree.hpp b/Runtime/Collision/COBBTree.hpp index 285a9bacf..38e89d42b 100644 --- a/Runtime/Collision/COBBTree.hpp +++ b/Runtime/Collision/COBBTree.hpp @@ -62,11 +62,14 @@ private: u32 x8_memsize = 0; /* CSimpleAllocator xc_ We're not using this but lets keep track*/ SIndexData x18_indexData; - std::unique_ptr x88_root; + std::unique_ptr x88_root; public: COBBTree()=default; COBBTree(const COBBTree::SIndexData&, const CNode*); COBBTree(CInputStream&); + + zeus::CAABox CalculateLocalAABox() const; + zeus::CAABox CalculateAABox(const zeus::CTransform&) const; }; } diff --git a/Runtime/Collision/CRayCastResult.cpp b/Runtime/Collision/CRayCastResult.cpp index 4825a19e1..5b6d0b815 100644 --- a/Runtime/Collision/CRayCastResult.cpp +++ b/Runtime/Collision/CRayCastResult.cpp @@ -3,8 +3,50 @@ namespace urde { -const CMaterialList& CRayCastResult::GetMaterial() const + +void CRayCastResult::MakeInvalid() +{ + /* NOTE: CRayCastResult: Enable this if it's required, this is a total guess - Phil */ +#if 0 + x0_time = 0.f; + x4_point.zeroOut(); + x10_plane.vec.zeroOut();; + x10_plane.d = 0.f; + x28_material = CMaterialList(); +#endif + x20_invalid = EInvalid::Invalid; +} + +bool CRayCastResult::IsInvalid() const +{ + return x20_invalid == EInvalid::Invalid; +} + +float CRayCastResult::GetTime() const +{ + return x0_time; +} + +const zeus::CVector3f&CRayCastResult::GetPoint() const +{ + return x4_point; +} + +const zeus::CPlane&CRayCastResult::GetPlane() const +{ + return x10_plane; +} + +const CMaterialList&CRayCastResult::GetMaterial() const { return x28_material; } + +void CRayCastResult::Transform(const zeus::CTransform& xf) +{ + x4_point = xf * x4_point; + x10_plane.vec = xf.rotate(x10_plane.vec); + x10_plane.d = x10_plane.vec.dot(x4_point); +} + } diff --git a/Runtime/Collision/CRayCastResult.hpp b/Runtime/Collision/CRayCastResult.hpp index f9f39ae8a..72b92cc28 100644 --- a/Runtime/Collision/CRayCastResult.hpp +++ b/Runtime/Collision/CRayCastResult.hpp @@ -9,25 +9,37 @@ namespace urde class CRayCastResult { public: - enum class EInvalid + enum class EInvalid : u8 { - Zero, - One + Invalid, + Valid }; private: - EInvalid invalid = EInvalid::Zero; - zeus::CVector3f x4_; - zeus::CVector3f x10_; + float x0_time; + zeus::CVector3f x4_point; + zeus::CPlane x10_plane; + EInvalid x20_invalid = EInvalid::Invalid; + /*u32 x24_; */ CMaterialList x28_material; public: CRayCastResult(); - CRayCastResult(const CRayCastResult& other, EInvalid) {} + CRayCastResult(const CRayCastResult& other, EInvalid invalid) + : x0_time(other.x0_time), + x4_point(other.x4_point), + x10_plane(other.x10_plane), + x20_invalid(invalid), + x28_material(other.x28_material) + { + } + CRayCastResult(float, const zeus::CVector3f&, const zeus::CPlane& plane, const CMaterialList& matList) : x28_material(matList) {} void MakeInvalid(); + bool IsInvalid() const; + float GetTime() const; const zeus::CVector3f& GetPoint() const; const zeus::CPlane& GetPlane() const; diff --git a/specter b/specter index d14a7aed7..5352a5842 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit d14a7aed7bd256191ed5bfbbb9a0f9cf4a141796 +Subproject commit 5352a5842ac0b2b6ba075f2c885fa172a93a54c0