mirror of https://github.com/AxioDL/metaforce.git
Merge pull request #119 from lioncash/constexpr
CollisionPrimitive: Make collision primitive types constexpr capable
This commit is contained in:
commit
ec7f6804cb
|
@ -5,7 +5,7 @@
|
||||||
#include "CInternalRayCastStructure.hpp"
|
#include "CInternalRayCastStructure.hpp"
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
const CCollisionPrimitive::Type CCollidableAABox::sType(CCollidableAABox::SetStaticTableIndex, "CCollidableAABox");
|
constexpr CCollisionPrimitive::Type sType(CCollidableAABox::SetStaticTableIndex, "CCollidableAABox");
|
||||||
u32 CCollidableAABox::sTableIndex = -1;
|
u32 CCollidableAABox::sTableIndex = -1;
|
||||||
|
|
||||||
CCollidableAABox::CCollidableAABox() = default;
|
CCollidableAABox::CCollidableAABox() = default;
|
||||||
|
|
|
@ -12,7 +12,6 @@ bool AABox_AABox_Bool(const CInternalCollisionStructure&);
|
||||||
} // namespace Collide
|
} // namespace Collide
|
||||||
|
|
||||||
class CCollidableAABox : public CCollisionPrimitive {
|
class CCollidableAABox : public CCollisionPrimitive {
|
||||||
static const Type sType;
|
|
||||||
static u32 sTableIndex;
|
static u32 sTableIndex;
|
||||||
|
|
||||||
zeus::CAABox x10_aabox;
|
zeus::CAABox x10_aabox;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "CCollidableCollisionSurface.hpp"
|
#include "CCollidableCollisionSurface.hpp"
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
const CCollisionPrimitive::Type CCollidableCollisionSurface::sType(CCollidableCollisionSurface::SetStaticTableIndex,
|
constexpr CCollisionPrimitive::Type sType(CCollidableCollisionSurface::SetStaticTableIndex,
|
||||||
"CCollidableCollisionSurface");
|
"CCollidableCollisionSurface");
|
||||||
u32 CCollidableCollisionSurface::sTableIndex = -1;
|
u32 CCollidableCollisionSurface::sTableIndex = -1;
|
||||||
|
|
||||||
const CCollisionPrimitive::Type& CCollidableCollisionSurface::GetType() { return sType; }
|
const CCollisionPrimitive::Type& CCollidableCollisionSurface::GetType() { return sType; }
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
class CCollidableCollisionSurface {
|
class CCollidableCollisionSurface {
|
||||||
static const CCollisionPrimitive::Type sType;
|
|
||||||
static u32 sTableIndex;
|
static u32 sTableIndex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
#include "CToken.hpp"
|
#include "CToken.hpp"
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
const CCollisionPrimitive::Type CCollidableOBBTreeGroup::sType(CCollidableOBBTreeGroup::SetStaticTableIndex,
|
constexpr CCollisionPrimitive::Type sType(CCollidableOBBTreeGroup::SetStaticTableIndex, "CCollidableOBBTreeGroup");
|
||||||
"CCollidableOBBTreeGroup");
|
|
||||||
u32 CCollidableOBBTreeGroup::sTableIndex = -1;
|
u32 CCollidableOBBTreeGroup::sTableIndex = -1;
|
||||||
|
|
||||||
CCollidableOBBTreeGroupContainer::CCollidableOBBTreeGroupContainer(CInputStream& in) {
|
CCollidableOBBTreeGroupContainer::CCollidableOBBTreeGroupContainer(CInputStream& in) {
|
||||||
|
|
|
@ -24,7 +24,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
class CCollidableOBBTreeGroup : public CCollisionPrimitive {
|
class CCollidableOBBTreeGroup : public CCollisionPrimitive {
|
||||||
static const Type sType;
|
|
||||||
static u32 sTableIndex;
|
static u32 sTableIndex;
|
||||||
const CCollidableOBBTreeGroupContainer* x10_container;
|
const CCollidableOBBTreeGroupContainer* x10_container;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "CInternalRayCastStructure.hpp"
|
#include "CInternalRayCastStructure.hpp"
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
const CCollisionPrimitive::Type CCollidableSphere::sType(CCollidableSphere::SetStaticTableIndex, "CCollidableSphere");
|
constexpr CCollisionPrimitive::Type sType(CCollidableSphere::SetStaticTableIndex, "CCollidableSphere");
|
||||||
u32 CCollidableSphere::sTableIndex = -1;
|
u32 CCollidableSphere::sTableIndex = -1;
|
||||||
|
|
||||||
namespace Collide {
|
namespace Collide {
|
||||||
|
@ -224,6 +224,8 @@ CRayCastResult CCollidableSphere::CastRayInternal(const CInternalRayCastStructur
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CCollisionPrimitive::Type& CCollidableSphere::GetType() { return sType; }
|
||||||
|
|
||||||
bool CCollidableSphere::CollideMovingAABox(const CInternalCollisionStructure& collision, const zeus::CVector3f& dir,
|
bool CCollidableSphere::CollideMovingAABox(const CInternalCollisionStructure& collision, const zeus::CVector3f& dir,
|
||||||
double& dOut, CCollisionInfo& infoOut) {
|
double& dOut, CCollisionInfo& infoOut) {
|
||||||
const CCollidableSphere& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
|
const CCollidableSphere& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
|
||||||
|
|
|
@ -12,8 +12,8 @@ bool Sphere_AABox_Bool(const CInternalCollisionStructure&);
|
||||||
bool Sphere_Sphere(const CInternalCollisionStructure&, CCollisionInfoList&);
|
bool Sphere_Sphere(const CInternalCollisionStructure&, CCollisionInfoList&);
|
||||||
bool Sphere_Sphere_Bool(const CInternalCollisionStructure&);
|
bool Sphere_Sphere_Bool(const CInternalCollisionStructure&);
|
||||||
} // namespace Collide
|
} // namespace Collide
|
||||||
|
|
||||||
class CCollidableSphere : public CCollisionPrimitive {
|
class CCollidableSphere : public CCollisionPrimitive {
|
||||||
static const Type sType;
|
|
||||||
static u32 sTableIndex;
|
static u32 sTableIndex;
|
||||||
|
|
||||||
zeus::CSphere x10_sphere;
|
zeus::CSphere x10_sphere;
|
||||||
|
@ -31,7 +31,7 @@ public:
|
||||||
FourCC GetPrimType() const override;
|
FourCC GetPrimType() const override;
|
||||||
CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const override;
|
CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const override;
|
||||||
|
|
||||||
static const Type& GetType() { return sType; }
|
static const Type& GetType();
|
||||||
static void SetStaticTableIndex(u32 index) { sTableIndex = index; }
|
static void SetStaticTableIndex(u32 index) { sTableIndex = index; }
|
||||||
static bool CollideMovingAABox(const CInternalCollisionStructure&, const zeus::CVector3f&, double&, CCollisionInfo&);
|
static bool CollideMovingAABox(const CInternalCollisionStructure&, const zeus::CVector3f&, double&, CCollisionInfo&);
|
||||||
static bool CollideMovingSphere(const CInternalCollisionStructure&, const zeus::CVector3f&, double&, CCollisionInfo&);
|
static bool CollideMovingSphere(const CInternalCollisionStructure&, const zeus::CVector3f&, double&, CCollisionInfo&);
|
||||||
|
|
|
@ -54,15 +54,15 @@ using PrimitiveSetter = void (*)(u32);
|
||||||
class CCollisionPrimitive {
|
class CCollisionPrimitive {
|
||||||
public:
|
public:
|
||||||
class Type {
|
class Type {
|
||||||
PrimitiveSetter x0_setter;
|
PrimitiveSetter x0_setter = nullptr;
|
||||||
const char* x4_info;
|
const char* x4_info = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Type() = default;
|
constexpr Type() noexcept = default;
|
||||||
Type(PrimitiveSetter setter, const char* info) : x0_setter(setter), x4_info(info) {}
|
constexpr Type(PrimitiveSetter setter, const char* info) noexcept : x0_setter(setter), x4_info(info) {}
|
||||||
|
|
||||||
const char* GetInfo() const { return x4_info; }
|
constexpr const char* GetInfo() const noexcept { return x4_info; }
|
||||||
PrimitiveSetter GetSetter() const { return x0_setter; }
|
constexpr PrimitiveSetter GetSetter() const noexcept { return x0_setter; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Comparison {
|
class Comparison {
|
||||||
|
@ -71,12 +71,12 @@ public:
|
||||||
const char* x8_type2;
|
const char* x8_type2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Comparison(ComparisonFunc collider, const char* type1, const char* type2)
|
constexpr Comparison(ComparisonFunc collider, const char* type1, const char* type2) noexcept
|
||||||
: x0_collider(collider), x4_type1(type1), x8_type2(type2) {}
|
: x0_collider(collider), x4_type1(type1), x8_type2(type2) {}
|
||||||
|
|
||||||
ComparisonFunc GetCollider() const { return x0_collider; }
|
constexpr ComparisonFunc GetCollider() const noexcept { return x0_collider; }
|
||||||
const char* GetType1() const { return x4_type1; }
|
constexpr const char* GetType1() const noexcept { return x4_type1; }
|
||||||
const char* GetType2() const { return x8_type2; }
|
constexpr const char* GetType2() const noexcept { return x8_type2; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class MovingComparison {
|
class MovingComparison {
|
||||||
|
@ -85,12 +85,12 @@ public:
|
||||||
const char* x8_type2;
|
const char* x8_type2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MovingComparison(MovingComparisonFunc collider, const char* type1, const char* type2)
|
constexpr MovingComparison(MovingComparisonFunc collider, const char* type1, const char* type2) noexcept
|
||||||
: x0_collider(collider), x4_type1(type1), x8_type2(type2) {}
|
: x0_collider(collider), x4_type1(type1), x8_type2(type2) {}
|
||||||
|
|
||||||
MovingComparisonFunc GetCollider() const { return x0_collider; }
|
constexpr MovingComparisonFunc GetCollider() const noexcept { return x0_collider; }
|
||||||
const char* GetType1() const { return x4_type1; }
|
constexpr const char* GetType1() const noexcept { return x4_type1; }
|
||||||
const char* GetType2() const { return x8_type2; }
|
constexpr const char* GetType2() const noexcept { return x8_type2; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class BooleanComparison {
|
class BooleanComparison {
|
||||||
|
@ -99,12 +99,12 @@ public:
|
||||||
const char* x8_type2;
|
const char* x8_type2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BooleanComparison(BooleanComparisonFunc collider, const char* type1, const char* type2)
|
constexpr BooleanComparison(BooleanComparisonFunc collider, const char* type1, const char* type2) noexcept
|
||||||
: x0_collider(collider), x4_type1(type1), x8_type2(type2) {}
|
: x0_collider(collider), x4_type1(type1), x8_type2(type2) {}
|
||||||
|
|
||||||
BooleanComparisonFunc GetCollider() const { return x0_collider; }
|
constexpr BooleanComparisonFunc GetCollider() const noexcept { return x0_collider; }
|
||||||
const char* GetType1() const { return x4_type1; }
|
constexpr const char* GetType1() const noexcept { return x4_type1; }
|
||||||
const char* GetType2() const { return x8_type2; }
|
constexpr const char* GetType2() const noexcept { return x8_type2; }
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue