mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 07:47:42 +00:00
Initial CMetroidAreaCollider implementations
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
#include "CMetroidAreaCollider.hpp"
|
||||
#include "CMaterialFilter.hpp"
|
||||
#include "CollisionUtil.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
u32 CMetroidAreaCollider::g_TrianglesProcessed = 0;
|
||||
|
||||
CBooleanAABoxAreaCache::CBooleanAABoxAreaCache(const zeus::CAABox& aabb, const CMaterialFilter& filter)
|
||||
: x0_aabb(aabb), x4_filter(filter), x8_center(aabb.center()), x14_halfExtent(aabb.extents())
|
||||
{}
|
||||
|
||||
CMetroidAreaCollider::COctreeLeafCache::COctreeLeafCache(const CAreaOctTree& octTree)
|
||||
: x0_octTree(octTree)
|
||||
{
|
||||
@@ -46,10 +54,48 @@ bool CMetroidAreaCollider::AABoxCollisionCheckBoolean_Cached(const COctreeLeafCa
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMetroidAreaCollider::AABoxCollisionCheckBoolean_Internal(const CAreaOctTree::Node& node,
|
||||
const CBooleanAABoxAreaCache& cache)
|
||||
{
|
||||
for (int i=0 ; i<8 ; ++i)
|
||||
{
|
||||
CAreaOctTree::Node::ETreeType type = node.GetChildType(i);
|
||||
if (type != CAreaOctTree::Node::ETreeType::Invalid)
|
||||
{
|
||||
CAreaOctTree::Node ch = node.GetChild(i);
|
||||
if (cache.x0_aabb.intersects(ch.GetBoundingBox()))
|
||||
{
|
||||
if (type == CAreaOctTree::Node::ETreeType::Leaf)
|
||||
{
|
||||
CAreaOctTree::TriListReference list = ch.GetTriangleArray();
|
||||
for (int j=0 ; j<list.GetSize() ; ++j)
|
||||
{
|
||||
++g_TrianglesProcessed;
|
||||
CCollisionSurface surf = ch.GetOwner().GetMasterListTriangle(list.GetAt(j));
|
||||
if (cache.x4_filter.Passes(CMaterialList(surf.GetSurfaceFlags())))
|
||||
{
|
||||
if (CollisionUtil::TriBoxOverlap(cache.x8_center, cache.x14_halfExtent,
|
||||
surf.GetVert(0), surf.GetVert(1), surf.GetVert(2)))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AABoxCollisionCheckBoolean_Internal(ch, cache))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMetroidAreaCollider::AABoxCollisionCheckBoolean(const CAreaOctTree& octTree, const zeus::CAABox& aabb,
|
||||
const CMaterialFilter& filter)
|
||||
{
|
||||
return false;
|
||||
CBooleanAABoxAreaCache cache(aabb, filter);
|
||||
return AABoxCollisionCheckBoolean_Internal(octTree.GetRootNode(), cache);
|
||||
}
|
||||
|
||||
bool CMetroidAreaCollider::SphereCollisionCheckBoolean_Cached(const COctreeLeafCache& leafCache, const zeus::CAABox& aabb,
|
||||
|
||||
Reference in New Issue
Block a user