2016-04-27 00:26:02 +00:00
|
|
|
#include "CCollisionPrimitive.hpp"
|
|
|
|
#include "CInternalRayCastStructure.hpp"
|
|
|
|
#include "CMaterialFilter.hpp"
|
2016-06-24 20:09:38 +00:00
|
|
|
#include "InternalColliders.hpp"
|
2016-04-27 00:26:02 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
2016-06-24 21:30:25 +00:00
|
|
|
std::unique_ptr<std::vector<CCollisionPrimitive::Type>> CCollisionPrimitive::sCollisionTypeList;
|
2017-01-04 04:08:30 +00:00
|
|
|
std::unique_ptr<std::vector<ComparisonFunc>> CCollisionPrimitive::sTableOfCollidables;
|
|
|
|
std::unique_ptr<std::vector<BooleanComparisonFunc>> CCollisionPrimitive::sTableOfBooleanCollidables;
|
|
|
|
std::unique_ptr<std::vector<MovingComparisonFunc>> CCollisionPrimitive::sTableOfMovingCollidables;
|
2017-01-21 15:46:51 +00:00
|
|
|
s32 CCollisionPrimitive::sNumTypes = 0;
|
2017-01-04 04:08:30 +00:00
|
|
|
bool CCollisionPrimitive::sTypesAdded = false;
|
2016-06-24 21:30:25 +00:00
|
|
|
bool CCollisionPrimitive::sTypesAdding = false;
|
2017-01-04 04:08:30 +00:00
|
|
|
bool CCollisionPrimitive::sCollidersAdded = false;
|
|
|
|
bool CCollisionPrimitive::sCollidersAdding = false;
|
|
|
|
CCollisionPrimitive::CCollisionPrimitive(const CMaterialList& list) : x8_material(list) {}
|
2016-04-27 00:26:02 +00:00
|
|
|
|
2017-01-04 04:08:30 +00:00
|
|
|
void CCollisionPrimitive::SetMaterial(const CMaterialList& material) { x8_material = material; }
|
2016-04-27 00:26:02 +00:00
|
|
|
|
2017-01-04 04:08:30 +00:00
|
|
|
const CMaterialList& CCollisionPrimitive::GetMaterial() const { return x8_material; }
|
2016-04-27 00:26:02 +00:00
|
|
|
|
2017-01-04 04:08:30 +00:00
|
|
|
CRayCastResult CCollisionPrimitive::CastRay(const zeus::CVector3f& start, const zeus::CVector3f& end, float d,
|
|
|
|
const CMaterialFilter& filter, const zeus::CTransform& xf) const
|
2016-04-27 00:26:02 +00:00
|
|
|
{
|
|
|
|
return CastRayInternal(CInternalRayCastStructure(start, end, d, xf, filter));
|
|
|
|
}
|
|
|
|
|
2016-06-24 20:09:38 +00:00
|
|
|
void CCollisionPrimitive::InitBeginTypes()
|
|
|
|
{
|
2016-06-24 21:30:25 +00:00
|
|
|
sCollisionTypeList.reset(new std::vector<CCollisionPrimitive::Type>());
|
|
|
|
sCollisionTypeList->reserve(3);
|
|
|
|
sTypesAdding = true;
|
|
|
|
InternalColliders::AddTypes();
|
2016-06-24 20:09:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCollisionPrimitive::InitAddType(const CCollisionPrimitive::Type& tp)
|
|
|
|
{
|
2016-06-24 21:30:25 +00:00
|
|
|
tp.GetSetter()(sCollisionTypeList->size());
|
2016-06-24 20:09:38 +00:00
|
|
|
|
2016-06-24 21:30:25 +00:00
|
|
|
sCollisionTypeList->reserve(sCollisionTypeList->size() + 1);
|
|
|
|
sCollisionTypeList->push_back(tp);
|
2016-06-24 20:09:38 +00:00
|
|
|
}
|
|
|
|
|
2017-01-04 04:08:30 +00:00
|
|
|
void CCollisionPrimitive::InitEndTypes() { sTypesAdding = false; }
|
|
|
|
|
|
|
|
void CCollisionPrimitive::InitBeginColliders()
|
2016-06-24 20:09:38 +00:00
|
|
|
{
|
2017-01-04 04:08:30 +00:00
|
|
|
sTableOfCollidables.reset(new std::vector<ComparisonFunc>());
|
|
|
|
sTableOfBooleanCollidables.reset(new std::vector<BooleanComparisonFunc>());
|
|
|
|
sTableOfMovingCollidables.reset(new std::vector<MovingComparisonFunc>());
|
|
|
|
sCollidersAdding = true;
|
|
|
|
InternalColliders::AddColliders();
|
2016-06-24 20:09:38 +00:00
|
|
|
}
|
|
|
|
|
2017-01-04 04:08:30 +00:00
|
|
|
void CCollisionPrimitive::InitAddBooleanCollider(const CCollisionPrimitive::BooleanComparison& cmp)
|
2016-06-24 20:09:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-04 04:08:30 +00:00
|
|
|
void CCollisionPrimitive::InitAddBooleanCollider(const BooleanComparisonFunc& cmp, const char* a, const char* b)
|
2016-06-24 20:09:38 +00:00
|
|
|
{
|
2017-01-04 04:08:30 +00:00
|
|
|
InitAddBooleanCollider({std::move(cmp), a, b});
|
2016-06-24 20:09:38 +00:00
|
|
|
}
|
|
|
|
|
2017-01-04 04:08:30 +00:00
|
|
|
void CCollisionPrimitive::InitAddMovingCollider(const CCollisionPrimitive::MovingComparison& cmp) {}
|
|
|
|
|
|
|
|
void CCollisionPrimitive::InitAddMovingCollider(const MovingComparisonFunc& cmp, const char* a, const char* b)
|
2016-06-24 20:09:38 +00:00
|
|
|
{
|
2017-01-04 04:08:30 +00:00
|
|
|
InitAddMovingCollider({std::move(cmp), a, b});
|
2016-06-24 20:09:38 +00:00
|
|
|
}
|
|
|
|
|
2017-01-21 15:46:51 +00:00
|
|
|
void CCollisionPrimitive::InitAddCollider(const CCollisionPrimitive::Comparison& cmp)
|
|
|
|
{
|
|
|
|
}
|
2017-01-04 04:08:30 +00:00
|
|
|
|
|
|
|
void CCollisionPrimitive::InitAddCollider(const ComparisonFunc& cmp, const char* a, const char* b)
|
|
|
|
{
|
|
|
|
InitAddCollider({std::move(cmp), a, b});
|
|
|
|
}
|
|
|
|
|
2017-01-21 15:46:51 +00:00
|
|
|
void CCollisionPrimitive::InitEndColliders()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCollisionPrimitive::Unitialize()
|
|
|
|
{
|
|
|
|
sCollidersAdding = false;
|
|
|
|
sTypesAdding = false;
|
|
|
|
sCollisionTypeList.reset();
|
|
|
|
sTableOfCollidables.reset();
|
|
|
|
sTableOfMovingCollidables.reset();
|
|
|
|
sTableOfBooleanCollidables.reset();
|
|
|
|
}
|
|
|
|
|
2017-01-04 04:08:30 +00:00
|
|
|
CCollisionPrimitive::Type::Type(const std::function<void(u32)>& 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; }
|
2016-04-27 00:26:02 +00:00
|
|
|
}
|