2016-04-17 22:38:05 +00:00
|
|
|
#ifndef __URDE_CCOLLISIONPRIMITIVE_HPP__
|
|
|
|
#define __URDE_CCOLLISIONPRIMITIVE_HPP__
|
|
|
|
|
2016-04-22 20:22:45 +00:00
|
|
|
#include "Collision/CMaterialList.hpp"
|
2016-04-27 00:26:02 +00:00
|
|
|
#include "CRayCastResult.hpp"
|
|
|
|
#include "zeus/CAABox.hpp"
|
|
|
|
|
2016-04-23 18:04:49 +00:00
|
|
|
#include <functional>
|
|
|
|
|
2016-04-17 22:38:05 +00:00
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2016-04-27 00:26:02 +00:00
|
|
|
class COBBTree;
|
2016-06-26 01:11:09 +00:00
|
|
|
class CInternalCollisionStructure;
|
|
|
|
class CCollisionInfo;
|
|
|
|
class CCollisionInfoList;
|
2016-04-27 00:26:02 +00:00
|
|
|
class CInternalRayCastStructure;
|
|
|
|
class CMaterialFilter;
|
2016-04-17 22:38:05 +00:00
|
|
|
class CCollisionPrimitive
|
|
|
|
{
|
2016-06-24 21:30:25 +00:00
|
|
|
public:
|
|
|
|
class Type;
|
|
|
|
private:
|
|
|
|
|
2016-04-22 20:22:45 +00:00
|
|
|
CMaterialList x8_material;
|
2016-06-24 21:30:25 +00:00
|
|
|
static std::unique_ptr<std::vector<Type>> sCollisionTypeList;
|
|
|
|
static bool sTypesAdding;
|
2016-04-17 22:38:05 +00:00
|
|
|
public:
|
2016-04-23 18:04:49 +00:00
|
|
|
class Type
|
2016-04-17 22:38:05 +00:00
|
|
|
{
|
2016-04-23 18:04:49 +00:00
|
|
|
std::function<void(u32)> x0_setter;
|
|
|
|
const char* x4_info;
|
|
|
|
public:
|
|
|
|
Type() = default;
|
2016-06-26 01:11:09 +00:00
|
|
|
Type(const std::function<void(u32)>& setter, const char * info);
|
2016-04-23 18:04:49 +00:00
|
|
|
|
2016-06-24 20:09:38 +00:00
|
|
|
const char* GetInfo() const;
|
2016-04-23 18:04:49 +00:00
|
|
|
|
2016-06-24 20:09:38 +00:00
|
|
|
std::function<void(u32)> GetSetter() const;
|
2016-04-17 22:38:05 +00:00
|
|
|
};
|
|
|
|
|
2016-06-26 01:11:09 +00:00
|
|
|
class Comparison
|
|
|
|
{
|
|
|
|
std::function<bool(const CInternalCollisionStructure&, CCollisionInfoList&)> x0_collider;
|
|
|
|
const char* x4_type1;
|
|
|
|
const char* x8_type2;
|
|
|
|
public:
|
|
|
|
Comparison(const std::function<bool(const CInternalCollisionStructure&, CCollisionInfoList&)>& collider,
|
|
|
|
const char* type1, const char* type2)
|
|
|
|
: x0_collider(collider),
|
|
|
|
x4_type1(type1),
|
|
|
|
x8_type2(type2)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::function<bool(const CInternalCollisionStructure&, CCollisionInfoList&)> GetCollider() const { return x0_collider; }
|
|
|
|
const char* GetType1() const { return x4_type1; }
|
|
|
|
const char* GetType2() const { return x8_type2; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MovingComparison
|
|
|
|
{
|
|
|
|
std::function<bool(const CInternalCollisionStructure&, const zeus::CVector2f&, double&,
|
|
|
|
CCollisionInfo&)> x0_collider;
|
|
|
|
const char* x4_type1;
|
|
|
|
const char* x8_type2;
|
|
|
|
public:
|
|
|
|
MovingComparison(const std::function<bool(const CInternalCollisionStructure&, const zeus::CVector2f&, double&,
|
|
|
|
CCollisionInfo&)>& collider, const char* type1, const char* type2)
|
|
|
|
: x0_collider(collider),
|
|
|
|
x4_type1(type1),
|
|
|
|
x8_type2(type2)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::function<bool(const CInternalCollisionStructure&, const zeus::CVector2f&, double&,
|
|
|
|
CCollisionInfo&)> GetCollider() const { return x0_collider; }
|
|
|
|
const char* GetType1() const { return x4_type1; }
|
|
|
|
const char* GetType2() const { return x8_type2; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class BooleanComparison
|
|
|
|
{
|
|
|
|
std::function<bool(const CInternalCollisionStructure&)> x0_collider;
|
|
|
|
const char* x4_type1;
|
|
|
|
const char* x8_type2;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BooleanComparison(const std::function<bool(const CInternalCollisionStructure&)>& collider, const char* type1,
|
|
|
|
const char* type2)
|
|
|
|
: x0_collider(collider),
|
|
|
|
x4_type1(type1),
|
|
|
|
x8_type2(type2)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::function<bool(const CInternalCollisionStructure&)> GetCollider() const { return x0_collider; }
|
|
|
|
const char* GetType1() const { return x4_type1; }
|
|
|
|
const char* GetType2() const { return x8_type2; }
|
|
|
|
};
|
|
|
|
|
2016-04-27 00:26:02 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
|
2016-04-17 22:38:05 +00:00
|
|
|
static void InitBeginTypes();
|
2016-04-23 18:04:49 +00:00
|
|
|
static void InitAddType(const Type& tp);
|
2016-04-17 22:38:05 +00:00
|
|
|
static void InitEndTypes();
|
2016-04-22 20:29:31 +00:00
|
|
|
|
|
|
|
static void InitBeginColliders();
|
2016-06-26 01:11:09 +00:00
|
|
|
static void InitAddBooleanCollider(const BooleanComparison& cmp);
|
|
|
|
static void InitAddMovingCollider(const MovingComparison& cmp);
|
|
|
|
static void InitAddCollider(const Comparison& cmp);
|
2016-06-24 20:09:38 +00:00
|
|
|
static void InitEndColliders();
|
2016-04-17 22:38:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __URDE_CCOLLISIONPRIMITIVE_HPP__
|