mirror of https://github.com/PrimeDecomp/prime.git
parent
c576574bde
commit
3787c422ed
|
@ -0,0 +1,30 @@
|
|||
#ifndef _CCOLLISIONINFOLIST
|
||||
#define _CCOLLISIONINFOLIST
|
||||
|
||||
#include "Collision/CCollisionInfo.hpp"
|
||||
|
||||
#include "rstl/reserved_vector.hpp"
|
||||
|
||||
class CCollisionInfoList {
|
||||
rstl::reserved_vector< CCollisionInfo, 32 > x0_list;
|
||||
|
||||
public:
|
||||
typedef rstl::reserved_vector< CCollisionInfo, 32 >::iterator iterator;
|
||||
typedef rstl::reserved_vector< CCollisionInfo, 32 >::const_iterator const_iterator;
|
||||
|
||||
void Add(const CCollisionInfo& info, bool swap) {
|
||||
if (x0_list.size() == 32)
|
||||
return;
|
||||
if (!swap)
|
||||
x0_list.push_back(info);
|
||||
else
|
||||
x0_list.push_back(info.GetSwapped());
|
||||
}
|
||||
|
||||
iterator end() { return x0_list.end(); }
|
||||
const_iterator end() const { return x0_list.end(); }
|
||||
iterator begin() { return x0_list.begin(); }
|
||||
const_iterator begin() const { return x0_list.begin(); }
|
||||
};
|
||||
|
||||
#endif // _CCOLLISIONINFOLIST
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef _CAABOXFILTER
|
||||
#define _CAABOXFILTER
|
||||
|
||||
#include "MetroidPrime/ICollisionFilter.hpp"
|
||||
|
||||
class CCollisionInfoList;
|
||||
|
||||
class CAABoxFilter : public ICollisionFilter {
|
||||
public:
|
||||
explicit CAABoxFilter(CActor& actor) : ICollisionFilter(actor) {}
|
||||
static void FilterBoxFloorCollisions(const CCollisionInfoList& in, CCollisionInfoList& out);
|
||||
void Filter(const CCollisionInfoList& in, CCollisionInfoList& out) const;
|
||||
};
|
||||
|
||||
#endif // _CAABOXFILTER
|
|
@ -0,0 +1,30 @@
|
|||
#include "MetroidPrime/CAABoxFilter.hpp"
|
||||
|
||||
#include "Collision/CCollisionInfoList.hpp"
|
||||
#include "Collision/CollisionUtil.hpp"
|
||||
|
||||
void CAABoxFilter::FilterBoxFloorCollisions(const CCollisionInfoList& in, CCollisionInfoList& out) {
|
||||
float minZ = 10000.f;
|
||||
|
||||
for (CCollisionInfoList::const_iterator it = in.begin(); it != in.end(); ++it) {
|
||||
if (it->GetMaterialLeft().HasMaterial(kMT_Wall) && it->GetPoint().GetZ() < minZ) {
|
||||
minZ = it->GetPoint().GetZ();
|
||||
}
|
||||
}
|
||||
|
||||
CCollisionInfoList temp;
|
||||
for (CCollisionInfoList::const_iterator it = in.begin(); it != in.end(); ++it) {
|
||||
if (it->GetMaterialLeft().HasMaterial(kMT_Floor)) {
|
||||
if (it->GetPoint().GetZ() < minZ) {
|
||||
temp.Add(*it, false);
|
||||
}
|
||||
} else {
|
||||
temp.Add(*it, false);
|
||||
}
|
||||
}
|
||||
CollisionUtil::AddAverageToFront(temp, out);
|
||||
}
|
||||
|
||||
void CAABoxFilter::Filter(const CCollisionInfoList& in, CCollisionInfoList& out) const {
|
||||
FilterBoxFloorCollisions(in, out);
|
||||
}
|
Loading…
Reference in New Issue