metaforce/Runtime/Collision/CCollisionPrimitive.cpp

70 lines
1.7 KiB
C++
Raw Normal View History

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;
bool CCollisionPrimitive::sTypesAdding = false;
2016-04-27 00:26:02 +00:00
CCollisionPrimitive::CCollisionPrimitive(const CMaterialList& list)
: x8_material(list)
{
}
void CCollisionPrimitive::SetMaterial(const CMaterialList& material)
{
x8_material = material;
}
2016-06-24 20:09:38 +00:00
const CMaterialList& CCollisionPrimitive::GetMaterial() const
2016-04-27 00:26:02 +00:00
{
return x8_material;
}
CRayCastResult CCollisionPrimitive::CastRay(const zeus::CVector3f& start, const zeus::CVector3f& end, float d, const
CMaterialFilter& filter, const zeus::CTransform& xf) const
{
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
}
void CCollisionPrimitive::InitEndTypes()
{
2016-06-24 21:30:25 +00:00
sTypesAdding = false;
2016-06-24 20:09:38 +00:00
}
CCollisionPrimitive::Type::Type(const std::function<void(u32)>& setter, const char *info)
2016-06-24 20:09:38 +00:00
: 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
}