Add CMetroidAreaCollider

This commit is contained in:
2022-10-20 20:26:38 -04:00
parent 865e2d58f2
commit 71ff684be4
14 changed files with 214 additions and 151 deletions

View File

@@ -69,6 +69,7 @@ public:
float lT, float hT, float maxT, const CVector3f& dirRecip) const;
};
CCollisionSurface GetMasterListTriangle(ushort idx) const;
// TODO
private:

View File

@@ -3,16 +3,18 @@
#include "types.h"
#include "Kyoto/Math/CVector3f.hpp"
#include "Kyoto/Math/CPlane.hpp"
#include "Kyoto/Math/CVector3f.hpp"
class CCollisionSurface {
public:
CCollisionSurface(const CVector3f&, const CVector3f&, const CVector3f&, uint flags);
CUnitVector3f GetNormal() const;
CPlane GetPlane() const;
uint GetSurfaceFlags() const { return x24_flags; }
const CVector3f& GetVert(int i) const { return (&x0_a)[i]; }
// GetPoint__17CCollisionSurfaceCFi ??
private:
CVector3f x0_a;
@@ -20,6 +22,6 @@ private:
CVector3f x18_c;
uint x24_flags;
};
//CHECK_SIZEOF(CCollisionSurface, 0x28)
CHECK_SIZEOF(CCollisionSurface, 0x28)
#endif // _CCOLLISIONSURFACE

View File

@@ -5,17 +5,48 @@
#include "WorldFormat/CAreaOctTree.hpp"
#include "Collision/CCollisionInfoList.hpp"
#include "Collision/CMaterialFilter.hpp"
#include "Collision/CMaterialList.hpp"
#include "Kyoto/Math/CAABox.hpp"
#include "Kyoto/Math/CPlane.hpp"
#include "Kyoto/Math/CVector3f.hpp"
#include "rstl/reserved_vector.hpp"
class CAABoxAreaCache {
public:
friend class CMetroidAreaCollider;
CAABoxAreaCache(const CAABox& aabb, const CPlane* pl, const CMaterialFilter& filter,
const CMaterialList& material, CCollisionInfoList& collisionList)
: x0_aabb(aabb)
, x4_planes(pl)
, x8_filter(filter)
, xc_material(material)
, x10_collisionList(collisionList)
, x14_center(aabb.GetCenterPoint())
, x20_halfExtent(aabb.GetHalfExtent()) {}
private:
const CAABox& x0_aabb;
const CPlane* x4_planes;
const CMaterialFilter& x8_filter;
const CMaterialList& xc_material;
CCollisionInfoList& x10_collisionList;
CVector3f x14_center;
CVector3f x20_halfExtent;
};
class CMetroidAreaCollider {
public:
class COctreeLeafCache {
public:
COctreeLeafCache(const CAreaOctTree& octTree);
void AddLeaf(const CAreaOctTree::Node& node);
uint GetNumLeaves() const { return x4_nodeCache.size(); }
const CAreaOctTree::Node& GetLeaf(int i) const { return x4_nodeCache[i]; }
int GetNumLeaves() const { return x4_nodeCache.size(); }
bool HasCacheOverflowed() const { return x908_24_overflow; }
const CAreaOctTree& GetOctTree() const { return x0_octTree; }
rstl::reserved_vector< CAreaOctTree::Node, 64 >::const_iterator begin() const {
@@ -31,10 +62,18 @@ public:
bool x908_24_overflow : 1;
};
// TODO
static bool ConvexPolyCollision(const CPlane* planes, const CVector3f* verts, CAABox& aabb);
static bool AABoxCollisionCheck_Cached(const COctreeLeafCache& leafCache, const CAABox& aabb,
const CMaterialFilter& filter,
const CMaterialList& matList, CCollisionInfoList& list);
private:
// TODO
static ushort sDupPrimitiveCheckCount;
static ushort sDupVertexList[0x2800];
static ushort sDupEdgeList[0x6000];
static ushort sDupTriangleList[0x4000];
static void ResetInternalCounters();
static bool AABoxCollisionCheck_Internal(const CAreaOctTree::Node&, CAABoxAreaCache&);
};
class CAreaCollisionCache {