2022-10-09 05:13:17 +00:00
|
|
|
#ifndef _CCOLLISIONPRIMITIVE
|
|
|
|
#define _CCOLLISIONPRIMITIVE
|
2022-09-18 05:55:13 +00:00
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
#include "Collision/CMaterialList.hpp"
|
|
|
|
|
|
|
|
#include "Kyoto/IObjectStore.hpp"
|
|
|
|
#include "Kyoto/Math/CAABox.hpp"
|
|
|
|
#include "Kyoto/Math/CTransform4f.hpp"
|
2022-12-24 08:06:45 +00:00
|
|
|
#include "rstl/single_ptr.hpp"
|
|
|
|
#include "rstl/vector.hpp"
|
2022-09-18 05:55:13 +00:00
|
|
|
|
|
|
|
class CRayCastResult;
|
2022-12-24 08:06:45 +00:00
|
|
|
class CCollisionInfoList;
|
|
|
|
class CInternalCollisionStructure;
|
2022-09-18 05:55:13 +00:00
|
|
|
class CInternalRayCastStructure;
|
2022-12-24 08:06:45 +00:00
|
|
|
class CCollisionInfo;
|
2022-09-18 05:55:13 +00:00
|
|
|
|
2022-12-24 08:06:45 +00:00
|
|
|
typedef void (*PrimitiveSetter)(uint);
|
|
|
|
|
|
|
|
typedef bool (*ComparisonFunc)(const CInternalCollisionStructure&, CCollisionInfoList&);
|
|
|
|
typedef bool (*BooleanComparisonFunc)(const CInternalCollisionStructure&);
|
|
|
|
typedef bool (*MovingComparisonFunc)(const CInternalCollisionStructure&, const CVector3f&, double&,
|
|
|
|
CCollisionInfo&);
|
2022-12-08 22:33:06 +00:00
|
|
|
|
2022-09-18 05:55:13 +00:00
|
|
|
class CCollisionPrimitive {
|
|
|
|
public:
|
2022-12-08 22:33:06 +00:00
|
|
|
class Type {
|
|
|
|
public:
|
|
|
|
Type(PrimitiveSetter setter, const char* info) : mSetter(setter), mInfo(info) {}
|
|
|
|
|
|
|
|
PrimitiveSetter GetSetter() const { return mSetter; }
|
|
|
|
const char* GetInfo() const { return mInfo; }
|
2022-12-24 08:06:45 +00:00
|
|
|
|
2022-12-08 22:33:06 +00:00
|
|
|
private:
|
|
|
|
PrimitiveSetter mSetter;
|
|
|
|
const char* mInfo;
|
|
|
|
};
|
|
|
|
|
2024-09-26 05:54:05 +00:00
|
|
|
class Comparison {};
|
2023-10-20 04:15:38 +00:00
|
|
|
|
2022-09-18 05:55:13 +00:00
|
|
|
CCollisionPrimitive(const CMaterialList& list);
|
|
|
|
|
2022-10-09 05:37:23 +00:00
|
|
|
virtual uint GetTableIndex() const = 0;
|
2024-09-26 05:54:05 +00:00
|
|
|
virtual void SetMaterial(const CMaterialList& other) { x8_material = other; }
|
2022-09-18 05:55:13 +00:00
|
|
|
virtual const CMaterialList& GetMaterial() const;
|
|
|
|
virtual CAABox CalculateAABox(const CTransform4f&) const = 0;
|
|
|
|
virtual CAABox CalculateLocalAABox() const = 0;
|
|
|
|
virtual FourCC GetPrimType() const = 0;
|
|
|
|
virtual ~CCollisionPrimitive();
|
|
|
|
virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const = 0;
|
|
|
|
|
2022-12-24 08:06:45 +00:00
|
|
|
static void InitBeginTypes();
|
|
|
|
static void InitAddType(const Type& type);
|
|
|
|
static void InitEndTypes();
|
2023-10-20 04:15:38 +00:00
|
|
|
static void InitBeginColliders();
|
|
|
|
static void InitAddCollider(const Comparison& comp);
|
|
|
|
static void InitAddCollider(ComparisonFunc comp, const char*, const char*);
|
|
|
|
static void InitAddBooleanCollider(BooleanComparisonFunc comp, const char*, const char*);
|
|
|
|
static void InitAddMovingCollider(MovingComparisonFunc comp, const char*, const char*);
|
|
|
|
static void InitEndColliders();
|
2022-11-14 23:08:47 +00:00
|
|
|
static void Uninitialize();
|
|
|
|
|
2022-09-18 05:55:13 +00:00
|
|
|
private:
|
2022-12-24 08:06:45 +00:00
|
|
|
static int sNumTypes;
|
|
|
|
static bool sInitComplete;
|
|
|
|
static bool sTypesAdded;
|
|
|
|
static bool sTypesAdding;
|
|
|
|
static bool sCollidersAdded;
|
|
|
|
static bool sCollidersAdding;
|
|
|
|
static rstl::single_ptr< rstl::vector< Type > > sCollisionTypeList;
|
|
|
|
static rstl::single_ptr< ComparisonFunc > sTableOfCollidables;
|
|
|
|
static rstl::single_ptr< BooleanComparisonFunc > sTableOfBooleanCollidables;
|
|
|
|
static rstl::single_ptr< MovingComparisonFunc > sTableOfMovingCollidables;
|
|
|
|
static ComparisonFunc sNullCollider;
|
|
|
|
static BooleanComparisonFunc sNullBooleanCollider;
|
|
|
|
static MovingComparisonFunc sNullMovingCollider;
|
|
|
|
|
2022-09-18 05:55:13 +00:00
|
|
|
uint x4_;
|
|
|
|
CMaterialList x8_material;
|
|
|
|
};
|
|
|
|
CHECK_SIZEOF(CCollisionPrimitive, 0x10)
|
|
|
|
|
|
|
|
inline CCollisionPrimitive::~CCollisionPrimitive() {}
|
|
|
|
|
2022-10-09 05:13:17 +00:00
|
|
|
#endif // _CCOLLISIONPRIMITIVE
|