mirror of https://github.com/AxioDL/metaforce.git
More collision imps and stubs
This commit is contained in:
parent
bacc98d4a6
commit
2af6117ef8
|
@ -0,0 +1,32 @@
|
|||
#include "CCollidableOBBTree.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CCollidableOBBTree::CCollidableOBBTree(const COBBTree* tree, const urde::CMaterialList& material)
|
||||
: CCollisionPrimitive(material),
|
||||
x10_tree((COBBTree*)tree)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FourCC CCollidableOBBTree::GetPrimType() const
|
||||
{
|
||||
return SBIG('OBBT');
|
||||
}
|
||||
|
||||
CRayCastResult CCollidableOBBTree::CastRayInternal(const CInternalRayCastStructure&) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
zeus::CAABox CCollidableOBBTree::CalculateAABox(const zeus::CTransform&) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
zeus::CAABox CCollidableOBBTree::CalculateLocalAABox() const
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,27 @@
|
|||
#ifndef __URDE_CCOLLIDABLEOBBTREE_HPP__
|
||||
#define __URDE_CCOLLIDABLEOBBTREE_HPP__
|
||||
|
||||
#include "Collision/CCollisionPrimitive.hpp"
|
||||
#include "COBBTree.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
class CCollidableOBBTree
|
||||
class CCollidableOBBTree : public CCollisionPrimitive
|
||||
{
|
||||
COBBTree* x10_tree = nullptr;
|
||||
u32 x14_ = 0;
|
||||
u32 x18_ = 0;
|
||||
u32 x1c_ = 0;
|
||||
public:
|
||||
CCollidableOBBTree(const COBBTree* tree, const CMaterialList& material);
|
||||
virtual ~CCollidableOBBTree() {}
|
||||
void ResetTestStats() const;
|
||||
void ResetTestStatsRecurse(const COBBTree::CNode&) const;
|
||||
u32 GetTableIndex() const { return -1; }
|
||||
zeus::CAABox CalculateAABox(const zeus::CTransform &) const;
|
||||
zeus::CAABox CalculateLocalAABox() const;
|
||||
virtual FourCC GetPrimType() const;
|
||||
virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#include "CCollidableOBBTreeGroup.hpp"
|
||||
#include "COBBTree.hpp"
|
||||
#include "CCollidableOBBTree.hpp"
|
||||
#include "CToken.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
const CCollisionPrimitive::Type CCollidableOBBTreeGroup::sType(CCollidableOBBTreeGroup::SetStaticTableIndex, "CCollidableOBBTreeGroup");
|
||||
u32 CCollidableOBBTreeGroup::sTableIndex = -1;
|
||||
|
||||
CCollidableOBBTreeGroup::CCollidableOBBTreeGroup(CInputStream& in)
|
||||
{
|
||||
|
@ -11,7 +13,49 @@ CCollidableOBBTreeGroup::CCollidableOBBTreeGroup(CInputStream& in)
|
|||
x0_trees.reserve(treeCount);
|
||||
|
||||
for (u32 i = 0 ; i < treeCount ; i++)
|
||||
x0_trees.push_back(in);
|
||||
{
|
||||
std::unique_ptr<COBBTree> tree(new COBBTree(in));
|
||||
x0_trees.push_back(std::move(tree));
|
||||
}
|
||||
|
||||
x10_aabbs.reserve(x0_trees.size());
|
||||
|
||||
for (const std::unique_ptr<COBBTree>& tree : x0_trees)
|
||||
x10_aabbs.push_back(CCollidableOBBTree(tree.get(), CMaterialList()).CalculateLocalAABox());
|
||||
}
|
||||
|
||||
u32 CCollidableOBBTreeGroup::GetTableIndex() const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
zeus::CAABox CCollidableOBBTreeGroup::CalculateAABox(const zeus::CTransform&) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
zeus::CAABox CCollidableOBBTreeGroup::CalculateLocalAABox() const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FourCC CCollidableOBBTreeGroup::GetPrimType() const
|
||||
{
|
||||
return SBIG('OBTG');
|
||||
}
|
||||
|
||||
CRayCastResult CCollidableOBBTreeGroup::CastRayInternal(const CInternalRayCastStructure&) const
|
||||
{
|
||||
}
|
||||
|
||||
const CCollisionPrimitive::Type& CCollidableOBBTreeGroup::GetType()
|
||||
{
|
||||
return sType;
|
||||
}
|
||||
|
||||
void CCollidableOBBTreeGroup::SetStaticTableIndex(u32 index)
|
||||
{
|
||||
sTableIndex = index;
|
||||
}
|
||||
|
||||
CFactoryFnReturn FCollidableOBBTreeGroupFactory(const SObjectTag &tag, CInputStream &in,
|
||||
|
|
|
@ -3,14 +3,31 @@
|
|||
|
||||
#include "IOStreams.hpp"
|
||||
#include "CFactoryMgr.hpp"
|
||||
#include "COBBTree.hpp"
|
||||
#include "zeus/CAABox.hpp"
|
||||
#include "CCollisionPrimitive.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class COBBTree;
|
||||
class CCollidableOBBTreeGroup
|
||||
class CCollidableOBBTreeGroup : public CCollisionPrimitive
|
||||
{
|
||||
std::vector<COBBTree> x0_trees;
|
||||
static const CCollisionPrimitive::Type sType;
|
||||
static u32 sTableIndex;
|
||||
std::vector<std::unique_ptr<COBBTree>> x0_trees;
|
||||
std::vector<zeus::CAABox> x10_aabbs;
|
||||
public:
|
||||
CCollidableOBBTreeGroup(CInputStream& in);
|
||||
virtual ~CCollidableOBBTreeGroup() {}
|
||||
|
||||
void ResetTestStats() const;
|
||||
virtual u32 GetTableIndex() const;
|
||||
virtual zeus::CAABox CalculateAABox(const zeus::CTransform&) const;
|
||||
virtual zeus::CAABox CalculateLocalAABox() const;
|
||||
virtual FourCC GetPrimType() const;
|
||||
virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const;
|
||||
|
||||
static const CCollisionPrimitive::Type& GetType();
|
||||
static void SetStaticTableIndex(u32 index);
|
||||
};
|
||||
|
||||
CFactoryFnReturn FCollidableOBBTreeGroupFactory(const SObjectTag &tag, CInputStream &in,
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#include "CCollisionPrimitive.hpp"
|
||||
#include "CInternalRayCastStructure.hpp"
|
||||
#include "CMaterialFilter.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
CCollisionPrimitive::CCollisionPrimitive(const CMaterialList& list)
|
||||
: x8_material(list)
|
||||
{
|
||||
}
|
||||
|
||||
void CCollisionPrimitive::SetMaterial(const CMaterialList& material)
|
||||
{
|
||||
x8_material = material;
|
||||
}
|
||||
|
||||
const CMaterialList&CCollisionPrimitive::GetMaterial() const
|
||||
{
|
||||
return x8_material;
|
||||
|
||||
}
|
||||
|
||||
CRayCastResult CCollisionPrimitive::CastRay(const zeus::CVector3f& start, const zeus::CVector3f& end, float d, const
|
||||
CMaterialFilter& filter, const zeus::CTransform& xf) const
|
||||
{
|
||||
return CastRayInternal(CInternalRayCastStructure(start, end, d, xf, filter));
|
||||
}
|
||||
|
||||
}
|
|
@ -2,11 +2,17 @@
|
|||
#define __URDE_CCOLLISIONPRIMITIVE_HPP__
|
||||
|
||||
#include "Collision/CMaterialList.hpp"
|
||||
#include "CRayCastResult.hpp"
|
||||
#include "zeus/CAABox.hpp"
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
class COBBTree;
|
||||
class CInternalRayCastStructure;
|
||||
class CMaterialFilter;
|
||||
class CCollisionPrimitive
|
||||
{
|
||||
CMaterialList x8_material;
|
||||
|
@ -34,6 +40,20 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
CCollisionPrimitive()=default;
|
||||
CCollisionPrimitive(const CMaterialList& list);
|
||||
virtual u32 GetTableIndex() const=0;
|
||||
virtual void SetMaterial(const CMaterialList&);
|
||||
virtual const CMaterialList& GetMaterial() const;
|
||||
virtual zeus::CAABox CalculateAABox(const zeus::CTransform&) const=0;
|
||||
virtual zeus::CAABox CalculateLocalAABox() const=0;
|
||||
virtual FourCC GetPrimType() const=0;
|
||||
virtual ~CCollisionPrimitive() {}
|
||||
virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const=0;
|
||||
CRayCastResult CastRay(const zeus::CVector3f&, const zeus::CVector3f&, float, const CMaterialFilter&,
|
||||
const zeus::CTransform&) const;
|
||||
|
||||
|
||||
static void InitBeginTypes();
|
||||
static void InitAddType(const Type& tp);
|
||||
static void InitEndTypes();
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
#include "CInternalRayCastStructure.hpp"
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef __URDE_CINTERNALRAYCASTSTRUCTURE_HPP__
|
||||
#define __URDE_CINTERNALRAYCASTSTRUCTURE_HPP__
|
||||
|
||||
#include "zeus/CTransform.hpp"
|
||||
#include "zeus/CMRay.hpp"
|
||||
#include "CMaterialFilter.hpp"
|
||||
namespace urde
|
||||
{
|
||||
class CInternalRayCastStructure
|
||||
{
|
||||
zeus::CMRay x0_ray;
|
||||
float x38_maxTime;
|
||||
zeus::CTransform x3c_xf;
|
||||
CMaterialFilter x6c_filter;
|
||||
public:
|
||||
CInternalRayCastStructure(const zeus::CVector3f& start, const zeus::CVector3f& end, float d, const zeus::CTransform& xf,
|
||||
const CMaterialFilter& filter)
|
||||
: x0_ray(start, end, d),
|
||||
x3c_xf(xf),
|
||||
x6c_filter(filter)
|
||||
{
|
||||
}
|
||||
|
||||
const zeus::CMRay& GetRay() const { return x0_ray; }
|
||||
const zeus::CVector3f& GetStart() const { return x0_ray.start; }
|
||||
const zeus::CVector3f& GetNormal() const { return x0_ray.normal; }
|
||||
float GetMaxTime() const { return 0.f; }
|
||||
const zeus::CTransform& GetTransform() const { return x3c_xf; }
|
||||
const CMaterialFilter& GetFilter() const { return x6c_filter; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __URDE_CINTERNALRAYCASTSTRUCTURE_HPP__
|
|
@ -5,8 +5,10 @@ set(COLLISION_SOURCES
|
|||
COBBTree.hpp COBBTree.cpp
|
||||
CCollidableOBBTree.hpp CCollidableOBBTree.cpp
|
||||
CCollidableOBBTreeGroup.hpp CCollidableOBBTreeGroup.cpp
|
||||
CCollisionPrimitive.hpp CCollisionPrimitive.cpp
|
||||
CMaterialList.hpp
|
||||
CMaterialFilter.hpp CMaterialFilter.cpp
|
||||
CInternalRayCastStructure.hpp CInternalRayCastStructure.cpp
|
||||
CRayCastResult.hpp CRayCastResult.cpp)
|
||||
|
||||
runtime_add_list(Collision COLLISION_SOURCES)
|
||||
|
|
|
@ -23,7 +23,8 @@ COBBTree::COBBTree(CInputStream& in)
|
|||
: x0_magic(verify_deaf_babe(in)),
|
||||
x4_version(verify_version(in)),
|
||||
x8_memsize(in.readUint32()),
|
||||
x18_indexData(in)
|
||||
x18_indexData(in),
|
||||
x88_root(new CNode(in))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -57,9 +58,65 @@ COBBTree::SIndexData::SIndexData(CInputStream& in)
|
|||
x60_.push_back(zeus::CVector3f::ReadBig(in));
|
||||
}
|
||||
|
||||
COBBTree::CNode::CNode(const zeus::CTransform& xf, const zeus::CVector3f& point,
|
||||
const COBBTree::CNode* left, const COBBTree::CNode* right,
|
||||
const COBBTree::CLeafData* leaf)
|
||||
: x0_obb(xf, point),
|
||||
x3c_isLeaf(leaf != nullptr)
|
||||
{
|
||||
x40_left.reset((CNode*)left);
|
||||
x44_right.reset((CNode*)right);
|
||||
x48_leaf.reset((CLeafData*)leaf);
|
||||
}
|
||||
|
||||
COBBTree::CNode::CNode(CInputStream& in)
|
||||
{
|
||||
x0_obb = zeus::COBBox::ReadBig(in);
|
||||
x3c_isLeaf = in.readBool();
|
||||
if (x3c_isLeaf)
|
||||
x48_leaf.reset(new CLeafData(in));
|
||||
else
|
||||
{
|
||||
x40_left.reset(new CNode(in));
|
||||
x44_right.reset(new CNode(in));
|
||||
}
|
||||
}
|
||||
|
||||
COBBTree::CNode* COBBTree::CNode::GetLeft() const
|
||||
{
|
||||
return x40_left.get();
|
||||
}
|
||||
|
||||
COBBTree::CNode*COBBTree::CNode::GetRight() const
|
||||
{
|
||||
return x44_right.get();
|
||||
}
|
||||
|
||||
COBBTree::CLeafData*COBBTree::CNode::GetLeafData() const
|
||||
{
|
||||
return x48_leaf.get();
|
||||
}
|
||||
|
||||
const zeus::COBBox& COBBTree::CNode::GetOBB() const
|
||||
{
|
||||
return x0_obb;
|
||||
}
|
||||
|
||||
COBBTree::CLeafData::CLeafData(const std::vector<u16>& surface)
|
||||
: x0_surface(surface)
|
||||
{
|
||||
}
|
||||
|
||||
const std::vector<u16>& COBBTree::CLeafData::GetSurfaceVector() const
|
||||
{
|
||||
return x0_surface;
|
||||
}
|
||||
|
||||
COBBTree::CLeafData::CLeafData(CInputStream& in)
|
||||
{
|
||||
u32 edgeCount = in.readUint32Big();
|
||||
for (u32 i = 0 ; i < edgeCount ; i++)
|
||||
x0_surface.push_back(in.readUint16Big());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,20 +23,36 @@ public:
|
|||
SIndexData(CInputStream&);
|
||||
};
|
||||
|
||||
class CNodeLeafData
|
||||
class CLeafData
|
||||
{
|
||||
std::vector<u16> x0_surface;
|
||||
public:
|
||||
CLeafData()=default;
|
||||
CLeafData(const std::vector<u16>&);
|
||||
CLeafData(CInputStream&);
|
||||
|
||||
const std::vector<u16>& GetSurfaceVector() const;
|
||||
};
|
||||
|
||||
class CNode
|
||||
{
|
||||
zeus::COBBox x0_obb;
|
||||
bool x3c_ = false;
|
||||
std::unique_ptr<CNode> x40_;
|
||||
std::unique_ptr<CNode> x44_;
|
||||
std::unique_ptr<CNodeLeafData> x48_;
|
||||
bool x3c_isLeaf = false;
|
||||
std::unique_ptr<CNode> x40_left;
|
||||
std::unique_ptr<CNode> x44_right;
|
||||
std::unique_ptr<CLeafData> x48_leaf;
|
||||
public:
|
||||
CNode() = default;
|
||||
CNode(const CNode&)=default;
|
||||
CNode(const zeus::CTransform&, const zeus::CVector3f&, const CNode*, const CNode*, const CLeafData*);
|
||||
CNode(CInputStream&);
|
||||
|
||||
bool WasHit() const;
|
||||
void SetWasHit(bool) const;
|
||||
CNode* GetLeft() const;
|
||||
CNode* GetRight() const;
|
||||
CLeafData* GetLeafData() const;
|
||||
const zeus::COBBox& GetOBB() const;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -46,10 +62,9 @@ private:
|
|||
u32 x8_memsize = 0;
|
||||
/* CSimpleAllocator xc_ We're not using this but lets keep track*/
|
||||
SIndexData x18_indexData;
|
||||
std::unique_ptr<CNode> x88_root;
|
||||
std::unique_ptr<const CNode> x88_root;
|
||||
public:
|
||||
|
||||
|
||||
COBBTree()=default;
|
||||
COBBTree(const COBBTree::SIndexData&, const CNode*);
|
||||
COBBTree(CInputStream&);
|
||||
};
|
||||
|
|
|
@ -1,2 +1,10 @@
|
|||
#include "CRayCastResult.hpp"
|
||||
|
||||
|
||||
namespace urde
|
||||
{
|
||||
const CMaterialList& CRayCastResult::GetMaterial() const
|
||||
{
|
||||
return x28_material;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,18 @@ private:
|
|||
CMaterialList x28_material;
|
||||
public:
|
||||
CRayCastResult();
|
||||
CRayCastResult(float, const zeus::CVector3f&, const zeus::CPlane, const CMaterialList& matList)
|
||||
CRayCastResult(const CRayCastResult& other, EInvalid) {}
|
||||
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;
|
||||
const CMaterialList& GetMaterial() const;
|
||||
void Transform(const zeus::CTransform&);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ protected:
|
|||
float xf0_inertialTensor;
|
||||
float xf4_inertialTensorRecip;
|
||||
zeus::CAABox x1a4_baseBoundingBox;
|
||||
CCollisionPrimitive x1c0_collisionPrimitive;
|
||||
std::unique_ptr<CCollisionPrimitive> x1c0_collisionPrimitive;
|
||||
zeus::CVector3f x1e8_primitiveOffset;
|
||||
float x23c_stepUpHeight;
|
||||
float x240_stepDownHeight;
|
||||
|
@ -114,8 +114,8 @@ public:
|
|||
return zeus::CTransform();
|
||||
}
|
||||
|
||||
const CCollisionPrimitive& GetCollisionPrimitive() const
|
||||
{ return x1c0_collisionPrimitive; }
|
||||
const CCollisionPrimitive* GetCollisionPrimitive() const
|
||||
{ return x1c0_collisionPrimitive.get(); }
|
||||
|
||||
void SetInertiaTensorScalar(float tensor)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef CWORLDLIGHT_HPP
|
||||
#define CWORLDLIGHT_HPP
|
||||
#ifndef __URDE_CWORLDLIGHT_HPP__
|
||||
#define __URDE_CWORLDLIGHT_HPP__
|
||||
|
||||
#include "Graphics/CLight.hpp"
|
||||
|
||||
|
@ -31,4 +31,4 @@ public:
|
|||
|
||||
}
|
||||
|
||||
#endif // CWORLDLIGHT_HPP
|
||||
#endif // __URDE_CWORLDLIGHT_HPP__
|
||||
|
|
Loading…
Reference in New Issue