mirror of https://github.com/AxioDL/metaforce.git
CCollisionSurface: Return std::array by reference from GetVerts()
Same behavior, facilitates better static analysis for out-of-bounds accesses, and also even allows size querying if necessary.
This commit is contained in:
parent
ecf3cfdb49
commit
c97fedd989
|
@ -9,7 +9,11 @@
|
|||
|
||||
namespace urde {
|
||||
class CCollisionSurface {
|
||||
std::array<zeus::CVector3f, 3> x0_data;
|
||||
public:
|
||||
using Vertices = std::array<zeus::CVector3f, 3>;
|
||||
|
||||
private:
|
||||
Vertices x0_data;
|
||||
u32 x24_flags;
|
||||
|
||||
public:
|
||||
|
@ -17,7 +21,7 @@ public:
|
|||
|
||||
zeus::CVector3f GetNormal() const;
|
||||
const zeus::CVector3f& GetVert(s32 idx) const { return x0_data[idx]; }
|
||||
const zeus::CVector3f* GetVerts() const { return x0_data.data(); }
|
||||
const Vertices& GetVerts() const { return x0_data; }
|
||||
zeus::CPlane GetPlane() const;
|
||||
u32 GetSurfaceFlags() const { return x24_flags; }
|
||||
};
|
||||
|
|
|
@ -199,8 +199,8 @@ static zeus::CVector3f ClipRayToPlane(const zeus::CVector3f& a, const zeus::CVec
|
|||
return (1.f - -plane.pointToPlaneDist(a) / (b - a).dot(plane.normal())) * (a - b) + b;
|
||||
}
|
||||
|
||||
bool CMetroidAreaCollider::ConvexPolyCollision(const std::array<zeus::CPlane, 6>& planes, const zeus::CVector3f* verts,
|
||||
zeus::CAABox& aabb) {
|
||||
bool CMetroidAreaCollider::ConvexPolyCollision(const std::array<zeus::CPlane, 6>& planes,
|
||||
const std::array<zeus::CVector3f, 3>& verts, zeus::CAABox& aabb) {
|
||||
std::array<rstl::reserved_vector<zeus::CVector3f, 20>, 2> vecs;
|
||||
|
||||
g_CalledClip += 1;
|
||||
|
|
|
@ -133,8 +133,8 @@ public:
|
|||
};
|
||||
static void BuildOctreeLeafCache(const CAreaOctTree::Node& root, const zeus::CAABox& aabb,
|
||||
CMetroidAreaCollider::COctreeLeafCache& cache);
|
||||
static bool ConvexPolyCollision(const std::array<zeus::CPlane, 6>& planes, const zeus::CVector3f* verts,
|
||||
zeus::CAABox& aabb);
|
||||
static bool ConvexPolyCollision(const std::array<zeus::CPlane, 6>& planes,
|
||||
const std::array<zeus::CVector3f, 3>& verts, zeus::CAABox& aabb);
|
||||
|
||||
static bool AABoxCollisionCheckBoolean_Cached(const COctreeLeafCache& leafCache, const zeus::CAABox& aabb,
|
||||
const CMaterialFilter& filter);
|
||||
|
|
|
@ -263,7 +263,7 @@ bool RaySphereIntersection(const zeus::CSphere& sphere, const zeus::CVector3f& p
|
|||
}
|
||||
|
||||
bool RayTriangleIntersection_Double(const zeus::CVector3f& point, const zeus::CVector3f& dir,
|
||||
const zeus::CVector3f* verts, double& d) {
|
||||
const std::array<zeus::CVector3f, 3>& verts, double& d) {
|
||||
const zeus::CVector3d v0tov1 = verts[1] - verts[0];
|
||||
const zeus::CVector3d v0tov2 = verts[2] - verts[0];
|
||||
const zeus::CVector3d cross0 = zeus::CVector3d(dir).cross(v0tov2);
|
||||
|
@ -293,8 +293,8 @@ bool RayTriangleIntersection_Double(const zeus::CVector3f& point, const zeus::CV
|
|||
return true;
|
||||
}
|
||||
|
||||
bool RayTriangleIntersection(const zeus::CVector3f& point, const zeus::CVector3f& dir, const zeus::CVector3f* verts,
|
||||
float& d) {
|
||||
bool RayTriangleIntersection(const zeus::CVector3f& point, const zeus::CVector3f& dir,
|
||||
const std::array<zeus::CVector3f, 3>& verts, float& d) {
|
||||
const zeus::CVector3f v0tov1 = verts[1] - verts[0];
|
||||
const zeus::CVector3f v0tov2 = verts[2] - verts[0];
|
||||
const zeus::CVector3f cross0 = dir.cross(v0tov2);
|
||||
|
|
|
@ -20,9 +20,9 @@ bool RaySphereIntersection_Double(const zeus::CSphere&, const zeus::CVector3f&,
|
|||
bool RaySphereIntersection(const zeus::CSphere& sphere, const zeus::CVector3f& pos, const zeus::CVector3f& dir,
|
||||
float mag, float& T, zeus::CVector3f& point);
|
||||
bool RayTriangleIntersection_Double(const zeus::CVector3f& point, const zeus::CVector3f& dir,
|
||||
const zeus::CVector3f* verts, double& d);
|
||||
bool RayTriangleIntersection(const zeus::CVector3f& point, const zeus::CVector3f& dir, const zeus::CVector3f* verts,
|
||||
float& d);
|
||||
const std::array<zeus::CVector3f, 3>& verts, double& d);
|
||||
bool RayTriangleIntersection(const zeus::CVector3f& point, const zeus::CVector3f& dir,
|
||||
const std::array<zeus::CVector3f, 3>& verts, float& d);
|
||||
void FilterOutBackfaces(const zeus::CVector3f& vec, const CCollisionInfoList& in, CCollisionInfoList& out);
|
||||
void FilterByClosestNormal(const zeus::CVector3f& norm, const CCollisionInfoList& in, CCollisionInfoList& out);
|
||||
bool AABoxAABoxIntersection(const zeus::CAABox& aabb0, const CMaterialList& list0, const zeus::CAABox& aabb1,
|
||||
|
|
Loading…
Reference in New Issue