More Collision imps

This commit is contained in:
Phillip Stephens 2016-06-24 14:30:25 -07:00
parent c66dac6df2
commit d3563ea86d
5 changed files with 30 additions and 3 deletions

View File

@ -2,6 +2,9 @@
namespace urde
{
const CCollisionPrimitive::Type CCollidableCollisionSurface::sType(CCollidableCollisionSurface::SetStaticTableIndex, "CCollidableCollisionSurface");
u32 CCollidableCollisionSurface::sTableIndex = -1;
const CCollisionPrimitive::Type& CCollidableCollisionSurface::GetType()
{
return sType;

View File

@ -30,4 +30,14 @@ CRayCastResult CCollidableSphere::CastRayInternal(const CInternalRayCastStructur
return {};
}
const CCollisionPrimitive::Type& CCollidableSphere::GetType()
{
return sType;
}
void CCollidableSphere::SetStaticTableIndex(u32 index)
{
sTableIndex = index;
}
}

View File

@ -17,7 +17,7 @@ public:
virtual FourCC GetPrimType() const;
virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const;
static const CCollisionPrimitive::Type& GetType();
static const Type& GetType();
static void SetStaticTableIndex(u32 index);
};
}

View File

@ -5,6 +5,8 @@
namespace urde
{
std::unique_ptr<std::vector<CCollisionPrimitive::Type>> CCollisionPrimitive::sCollisionTypeList;
bool CCollisionPrimitive::sTypesAdding = false;
CCollisionPrimitive::CCollisionPrimitive(const CMaterialList& list)
: x8_material(list)
{
@ -29,17 +31,23 @@ CRayCastResult CCollisionPrimitive::CastRay(const zeus::CVector3f& start, const
void CCollisionPrimitive::InitBeginTypes()
{
sCollisionTypeList.reset(new std::vector<CCollisionPrimitive::Type>());
sCollisionTypeList->reserve(3);
sTypesAdding = true;
InternalColliders::AddTypes();
}
void CCollisionPrimitive::InitAddType(const CCollisionPrimitive::Type& tp)
{
tp.GetSetter()(sCollisionTypeList->size());
sCollisionTypeList->reserve(sCollisionTypeList->size() + 1);
sCollisionTypeList->push_back(tp);
}
void CCollisionPrimitive::InitEndTypes()
{
sTypesAdding = false;
}
CCollisionPrimitive::Type::Type(std::function<void (unsigned int)> setter, const char *info)

View File

@ -15,7 +15,13 @@ class CInternalRayCastStructure;
class CMaterialFilter;
class CCollisionPrimitive
{
public:
class Type;
private:
CMaterialList x8_material;
static std::unique_ptr<std::vector<Type>> sCollisionTypeList;
static bool sTypesAdding;
public:
class Type
{