2016-04-26 10:40:56 +00:00
|
|
|
#ifndef __URDE_COBBTREE_HPP__
|
|
|
|
#define __URDE_COBBTREE_HPP__
|
|
|
|
#include "RetroTypes.hpp"
|
|
|
|
#include "CCollisionEdge.hpp"
|
2016-07-28 06:37:50 +00:00
|
|
|
#include "CCollisionSurface.hpp"
|
2016-04-26 10:40:56 +00:00
|
|
|
#include "zeus/CVector3f.hpp"
|
|
|
|
#include "zeus/COBBox.hpp"
|
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
class COBBTree
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct SIndexData
|
|
|
|
{
|
2016-07-28 06:37:50 +00:00
|
|
|
std::vector<u32> x0_materials;
|
|
|
|
std::vector<u8> x10_vertMaterials;
|
|
|
|
std::vector<u8> x20_edgeMaterials;
|
|
|
|
std::vector<u8> x30_surfaceMaterials;
|
|
|
|
std::vector<CCollisionEdge> x40_edges;
|
|
|
|
std::vector<u16> x50_surfaceIndices;
|
|
|
|
std::vector<zeus::CVector3f> x60_vertices;
|
2016-04-26 10:40:56 +00:00
|
|
|
SIndexData()=default;
|
|
|
|
SIndexData(CInputStream&);
|
|
|
|
};
|
|
|
|
|
2016-04-27 00:26:02 +00:00
|
|
|
class CLeafData
|
2016-04-26 10:40:56 +00:00
|
|
|
{
|
2016-04-27 00:26:02 +00:00
|
|
|
std::vector<u16> x0_surface;
|
|
|
|
public:
|
|
|
|
CLeafData()=default;
|
|
|
|
CLeafData(const std::vector<u16>&);
|
|
|
|
CLeafData(CInputStream&);
|
|
|
|
|
|
|
|
const std::vector<u16>& GetSurfaceVector() const;
|
2016-06-24 20:09:38 +00:00
|
|
|
size_t GetMemoryUsage() const;
|
2016-04-26 10:40:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CNode
|
|
|
|
{
|
|
|
|
zeus::COBBox x0_obb;
|
2016-04-27 00:26:02 +00:00
|
|
|
bool x3c_isLeaf = false;
|
|
|
|
std::unique_ptr<CNode> x40_left;
|
|
|
|
std::unique_ptr<CNode> x44_right;
|
|
|
|
std::unique_ptr<CLeafData> x48_leaf;
|
2016-04-26 10:40:56 +00:00
|
|
|
public:
|
|
|
|
CNode() = default;
|
2016-04-27 00:26:02 +00:00
|
|
|
CNode(const CNode&)=default;
|
|
|
|
CNode(const zeus::CTransform&, const zeus::CVector3f&, const CNode*, const CNode*, const CLeafData*);
|
2016-04-26 10:40:56 +00:00
|
|
|
CNode(CInputStream&);
|
2016-04-27 00:26:02 +00:00
|
|
|
|
|
|
|
bool WasHit() const;
|
2016-06-24 20:09:38 +00:00
|
|
|
void SetHit(bool) const;
|
2016-04-27 00:26:02 +00:00
|
|
|
CNode* GetLeft() const;
|
|
|
|
CNode* GetRight() const;
|
|
|
|
CLeafData* GetLeafData() const;
|
|
|
|
const zeus::COBBox& GetOBB() const;
|
2016-06-24 20:09:38 +00:00
|
|
|
size_t GetMemoryUsage() const;
|
2016-04-26 10:40:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
u32 x0_magic = 0;
|
|
|
|
u32 x4_version = 0;
|
|
|
|
u32 x8_memsize = 0;
|
|
|
|
/* CSimpleAllocator xc_ We're not using this but lets keep track*/
|
|
|
|
SIndexData x18_indexData;
|
2016-04-27 02:41:00 +00:00
|
|
|
std::unique_ptr<CNode> x88_root;
|
2016-04-26 10:40:56 +00:00
|
|
|
public:
|
2016-04-27 00:26:02 +00:00
|
|
|
COBBTree()=default;
|
2016-04-26 10:40:56 +00:00
|
|
|
COBBTree(const COBBTree::SIndexData&, const CNode*);
|
|
|
|
COBBTree(CInputStream&);
|
2016-04-27 02:41:00 +00:00
|
|
|
|
2016-07-28 07:33:55 +00:00
|
|
|
CCollisionSurface GetSurface(u16) const;
|
2016-04-27 02:41:00 +00:00
|
|
|
zeus::CAABox CalculateLocalAABox() const;
|
|
|
|
zeus::CAABox CalculateAABox(const zeus::CTransform&) const;
|
2016-04-26 10:40:56 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __URDE_COBBTREE_HPP__
|