mirror of https://github.com/AxioDL/metaforce.git
Initial Collision stubs
This commit is contained in:
parent
40cd1226fa
commit
c66dac6df2
|
@ -1,6 +1,51 @@
|
|||
#include "CCollidableAABox.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
const CCollisionPrimitive::Type CCollidableAABox::sType(CCollidableAABox::SetStaticTableIndex, "CCollidableAABox");
|
||||
u32 CCollidableAABox::sTableIndex = -1;
|
||||
|
||||
CCollidableAABox::CCollidableAABox()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
zeus::CAABox CCollidableAABox::Transform(const zeus::CTransform& xf) const
|
||||
{
|
||||
return {xf.origin + x10_aabox.min, xf.origin + x10_aabox.max};
|
||||
}
|
||||
|
||||
u32 CCollidableAABox::GetTableIndex() const
|
||||
{
|
||||
return sTableIndex;
|
||||
}
|
||||
|
||||
zeus::CAABox CCollidableAABox::CalculateAABox(const zeus::CTransform& xf) const
|
||||
{
|
||||
return Transform(xf);
|
||||
}
|
||||
|
||||
zeus::CAABox CCollidableAABox::CalculateLocalAABox() const
|
||||
{
|
||||
return x10_aabox;
|
||||
}
|
||||
|
||||
FourCC CCollidableAABox::GetPrimType() const
|
||||
{
|
||||
return SBIG('AABX');
|
||||
}
|
||||
|
||||
CRayCastResult CCollidableAABox::CastRayInternal(const CInternalRayCastStructure &) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
const CCollisionPrimitive::Type& CCollidableAABox::GetType()
|
||||
{
|
||||
return sType;
|
||||
}
|
||||
|
||||
void CCollidableAABox::SetStaticTableIndex(u32 index)
|
||||
{
|
||||
sTableIndex = index;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,29 @@
|
|||
#ifndef CCOLLIDABLEAABOX_HPP
|
||||
#define CCOLLIDABLEAABOX_HPP
|
||||
#ifndef __URDE_CCOLLIDABLEAABOX_HPP__
|
||||
#define __URDE_CCOLLIDABLEAABOX_HPP__
|
||||
|
||||
#include "CCollisionPrimitive.hpp"
|
||||
|
||||
class CCollidableAABox
|
||||
namespace urde
|
||||
{
|
||||
class CCollidableAABox : public CCollisionPrimitive
|
||||
{
|
||||
static const Type sType;
|
||||
static u32 sTableIndex;
|
||||
|
||||
zeus::CAABox x10_aabox;
|
||||
public:
|
||||
CCollidableAABox();
|
||||
};
|
||||
|
||||
#endif // CCOLLIDABLEAABOX_HPP
|
||||
zeus::CAABox Transform(const zeus::CTransform&) 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);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __URDE_CCOLLIDABLEAABOX_HPP__
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#include "CCollidableCollisionSurface.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
const CCollisionPrimitive::Type& CCollidableCollisionSurface::GetType()
|
||||
{
|
||||
return sType;
|
||||
}
|
||||
|
||||
void CCollidableCollisionSurface::SetStaticTableIndex(u32 index)
|
||||
{
|
||||
sTableIndex = index;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef __URDE_COLLIDABLECOLLISIONSURFACE_HPP__
|
||||
#define __URDE_COLLIDABLECOLLISIONSURFACE_HPP__
|
||||
|
||||
#include "CCollisionPrimitive.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class CCollidableCollisionSurface
|
||||
{
|
||||
static const CCollisionPrimitive::Type sType;
|
||||
static u32 sTableIndex;
|
||||
public:
|
||||
static const CCollisionPrimitive::Type& GetType();
|
||||
static void SetStaticTableIndex(u32 index);
|
||||
};
|
||||
}
|
||||
#endif // __URDE_COLLIDABLECOLLISIONSURFACE_HPP__
|
|
@ -11,7 +11,7 @@ namespace urde
|
|||
{
|
||||
class CCollidableOBBTreeGroup : public CCollisionPrimitive
|
||||
{
|
||||
static const CCollisionPrimitive::Type sType;
|
||||
static const Type sType;
|
||||
static u32 sTableIndex;
|
||||
std::vector<std::unique_ptr<COBBTree>> x0_trees;
|
||||
std::vector<zeus::CAABox> x10_aabbs;
|
||||
|
@ -26,7 +26,7 @@ public:
|
|||
virtual FourCC GetPrimType() const;
|
||||
virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const;
|
||||
|
||||
static const CCollisionPrimitive::Type& GetType();
|
||||
static const Type& GetType();
|
||||
static void SetStaticTableIndex(u32 index);
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#include "CCollidableSphere.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
const CCollisionPrimitive::Type CCollidableSphere::sType(CCollidableSphere::SetStaticTableIndex, "CCollidableSphere");
|
||||
u32 CCollidableSphere::sTableIndex = -1;
|
||||
|
||||
u32 CCollidableSphere::GetTableIndex() const
|
||||
{
|
||||
return sTableIndex;
|
||||
}
|
||||
|
||||
zeus::CAABox CCollidableSphere::CalculateAABox(const zeus::CTransform &) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
zeus::CAABox CCollidableSphere::CalculateLocalAABox() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
FourCC CCollidableSphere::GetPrimType() const
|
||||
{
|
||||
return SBIG('SPHR');
|
||||
}
|
||||
|
||||
CRayCastResult CCollidableSphere::CastRayInternal(const CInternalRayCastStructure &) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef __URDE_CCOLLIDALBESPHERE_HPP
|
||||
#define __URDE_CCOLLIDALBESPHERE_HPP
|
||||
|
||||
#include "CCollisionPrimitive.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class CCollidableSphere : public CCollisionPrimitive
|
||||
{
|
||||
static const Type sType;
|
||||
static u32 sTableIndex;
|
||||
public:
|
||||
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __URDE_CCOLLIDALBESPHERE_HPP
|
|
@ -1,6 +1,7 @@
|
|||
#include "CCollisionPrimitive.hpp"
|
||||
#include "CInternalRayCastStructure.hpp"
|
||||
#include "CMaterialFilter.hpp"
|
||||
#include "InternalColliders.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
@ -26,4 +27,35 @@ CRayCastResult CCollisionPrimitive::CastRay(const zeus::CVector3f& start, const
|
|||
return CastRayInternal(CInternalRayCastStructure(start, end, d, xf, filter));
|
||||
}
|
||||
|
||||
void CCollisionPrimitive::InitBeginTypes()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CCollisionPrimitive::InitAddType(const CCollisionPrimitive::Type& tp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CCollisionPrimitive::InitEndTypes()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CCollisionPrimitive::Type::Type(std::function<void (unsigned int)> setter, const char *info)
|
||||
: x0_setter(setter),
|
||||
x4_info(info)
|
||||
{
|
||||
}
|
||||
|
||||
const char *CCollisionPrimitive::Type::GetInfo() const
|
||||
{
|
||||
return x4_info;
|
||||
}
|
||||
|
||||
std::function<void (u32)> CCollisionPrimitive::Type::GetSetter() const
|
||||
{
|
||||
return x0_setter;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,21 +23,11 @@ public:
|
|||
const char* x4_info;
|
||||
public:
|
||||
Type() = default;
|
||||
Type(std::function<void(unsigned int)> setter, const char * info)
|
||||
: x0_setter(setter),
|
||||
x4_info(info)
|
||||
{
|
||||
}
|
||||
Type(std::function<void(unsigned int)> setter, const char * info);
|
||||
|
||||
const char* GetInfo() const
|
||||
{
|
||||
return x4_info;
|
||||
}
|
||||
const char* GetInfo() const;
|
||||
|
||||
std::function<void(u32)> GetSetter() const
|
||||
{
|
||||
return x0_setter;
|
||||
}
|
||||
std::function<void(u32)> GetSetter() const;
|
||||
};
|
||||
|
||||
CCollisionPrimitive()=default;
|
||||
|
@ -60,6 +50,7 @@ public:
|
|||
|
||||
static void InitBeginColliders();
|
||||
static void InitAddCollider(const Type& tp);
|
||||
static void InitEndColliders();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#include "CCollisionSurface.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
CCollisionSurface::CCollisionSurface(const zeus::CVector3f& a, const zeus::CVector3f& b, const zeus::CVector3f& c, u32 flags)
|
||||
: x0_a(a),
|
||||
xc_b(b),
|
||||
x18_c(c),
|
||||
x24_flags(flags)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef __URDE_CCOLLISIONSURFACE_HPP__
|
||||
#define __URDE_CCOLLISIONSURFACE_HPP__
|
||||
|
||||
#include "zeus/zeus.hpp"
|
||||
#include "RetroTypes.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class CCollisionSurface
|
||||
{
|
||||
zeus::CVector3f x0_a;
|
||||
zeus::CVector3f xc_b;
|
||||
zeus::CVector3f x18_c;
|
||||
u32 x24_flags;
|
||||
public:
|
||||
CCollisionSurface(const zeus::CVector3f&, const zeus::CVector3f&, const zeus::CVector3f&, u32);
|
||||
|
||||
zeus::CVector3f GetPoint(u32) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __URDE_CCOLLISIONSURFACE_HPP__
|
|
@ -1 +1,13 @@
|
|||
#include "CMaterialFilter.hpp"
|
||||
#include "CGameCollision.hpp"
|
||||
#include "CCollidableOBBTreeGroup.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
void CGameCollision::InitCollision()
|
||||
{
|
||||
CCollisionPrimitive::InitBeginTypes();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
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; }
|
||||
float GetMaxTime() const { return x38_maxTime; }
|
||||
const zeus::CTransform& GetTransform() const { return x3c_xf; }
|
||||
const CMaterialFilter& GetFilter() const { return x6c_filter; }
|
||||
};
|
||||
|
|
|
@ -2,7 +2,12 @@ set(COLLISION_SOURCES
|
|||
CGameCollision.hpp CGameCollision.cpp
|
||||
CCollisionInfo.hpp CCollisionInfo.cpp
|
||||
CCollisionEdge.hpp CCollisionEdge.cpp
|
||||
CCollisionSurface.hpp CCollisionSurface.cpp
|
||||
InternalColliders.hpp InternalColliders.cpp
|
||||
COBBTree.hpp COBBTree.cpp
|
||||
CCollidableAABox.hpp CCollidableAABox.cpp
|
||||
CCollidableCollisionSurface.hpp CCollidableCollisionSurface.cpp
|
||||
CCollidableSphere.hpp CCollidableSphere.cpp
|
||||
CCollidableOBBTree.hpp CCollidableOBBTree.cpp
|
||||
CCollidableOBBTreeGroup.hpp CCollidableOBBTreeGroup.cpp
|
||||
CCollisionPrimitive.hpp CCollisionPrimitive.cpp
|
||||
|
|
|
@ -15,7 +15,9 @@ u32 verify_version(CInputStream& in)
|
|||
return in.readUint32Big();
|
||||
}
|
||||
|
||||
COBBTree::COBBTree(const COBBTree::SIndexData&, const COBBTree::CNode*)
|
||||
COBBTree::COBBTree(const SIndexData& indexData, const CNode* root)
|
||||
: x18_indexData(indexData),
|
||||
x88_root((CNode*)root)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -114,6 +116,25 @@ const zeus::COBBox& COBBTree::CNode::GetOBB() const
|
|||
return x0_obb;
|
||||
}
|
||||
|
||||
size_t COBBTree::CNode::GetMemoryUsage() const
|
||||
{
|
||||
size_t ret = 0;
|
||||
if (x3c_isLeaf)
|
||||
ret = x48_leaf->GetMemoryUsage() + 80;
|
||||
else
|
||||
{
|
||||
if (x40_left)
|
||||
ret = x40_left->GetMemoryUsage() + 80;
|
||||
if (x44_right)
|
||||
ret += x44_right->GetMemoryUsage();
|
||||
}
|
||||
|
||||
if (!(ret & 3))
|
||||
return ret;
|
||||
|
||||
return ret + ((ret & 3) - 4);
|
||||
}
|
||||
|
||||
COBBTree::CLeafData::CLeafData(const std::vector<u16>& surface)
|
||||
: x0_surface(surface)
|
||||
{
|
||||
|
@ -124,6 +145,14 @@ const std::vector<u16>& COBBTree::CLeafData::GetSurfaceVector() const
|
|||
return x0_surface;
|
||||
}
|
||||
|
||||
size_t COBBTree::CLeafData::GetMemoryUsage() const
|
||||
{
|
||||
size_t ret = (x0_surface.size() * 2) + 16;
|
||||
if (!(ret & 3))
|
||||
return ret;
|
||||
return ret + ((ret & 3) - 4);
|
||||
}
|
||||
|
||||
COBBTree::CLeafData::CLeafData(CInputStream& in)
|
||||
{
|
||||
u32 edgeCount = in.readUint32Big();
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
CLeafData(CInputStream&);
|
||||
|
||||
const std::vector<u16>& GetSurfaceVector() const;
|
||||
size_t GetMemoryUsage() const;
|
||||
};
|
||||
|
||||
class CNode
|
||||
|
@ -48,11 +49,12 @@ public:
|
|||
CNode(CInputStream&);
|
||||
|
||||
bool WasHit() const;
|
||||
void SetWasHit(bool) const;
|
||||
void SetHit(bool) const;
|
||||
CNode* GetLeft() const;
|
||||
CNode* GetRight() const;
|
||||
CLeafData* GetLeafData() const;
|
||||
const zeus::COBBox& GetOBB() const;
|
||||
size_t GetMemoryUsage() const;
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#include "InternalColliders.hpp"
|
||||
#include "CCollidableAABox.hpp"
|
||||
#include "CCollidableCollisionSurface.hpp"
|
||||
#include "CCollidableSphere.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
namespace InternalColliders
|
||||
{
|
||||
void AddTypes()
|
||||
{
|
||||
CCollisionPrimitive::InitAddType(CCollidableAABox::GetType());
|
||||
CCollisionPrimitive::InitAddType(CCollidableCollisionSurface::GetType());
|
||||
CCollisionPrimitive::InitAddType(CCollidableSphere::GetType());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef __URDE_INTERNALCOLLIDERS_HPP__
|
||||
#define __URDE_INTERNALCOLLIDERS_HPP__
|
||||
|
||||
namespace urde
|
||||
{
|
||||
namespace InternalColliders
|
||||
{
|
||||
void AddTypes();
|
||||
}
|
||||
}
|
||||
#endif // __URDE_INTERNALCOLLIDERS_HPP__
|
Loading…
Reference in New Issue