mirror of https://github.com/AxioDL/metaforce.git
CCollisionSurface: Collapse separate CVector3f instances into std::array
Will allow converting GetVertices() over to returning a reference to std::array, rather than simply a pointer.
This commit is contained in:
parent
41c2ede092
commit
ecf3cfdb49
|
@ -5,16 +5,16 @@
|
|||
namespace urde {
|
||||
CCollisionSurface::CCollisionSurface(const zeus::CVector3f& a, const zeus::CVector3f& b, const zeus::CVector3f& c,
|
||||
u32 flags)
|
||||
: x0_a(a), xc_b(b), x18_c(c), x24_flags(flags) {}
|
||||
: x0_data{a, b, c}, x24_flags(flags) {}
|
||||
|
||||
zeus::CVector3f CCollisionSurface::GetNormal() const {
|
||||
zeus::CVector3f v1 = (xc_b - x0_a).cross(x18_c - x0_a);
|
||||
const zeus::CVector3f v1 = (x0_data[1] - x0_data[0]).cross(x0_data[2] - x0_data[0]);
|
||||
return zeus::CUnitVector3f(v1, true);
|
||||
}
|
||||
|
||||
zeus::CPlane CCollisionSurface::GetPlane() const {
|
||||
zeus::CVector3f norm = GetNormal();
|
||||
return {norm, norm.dot(x0_a)};
|
||||
const zeus::CVector3f norm = GetNormal();
|
||||
return {norm, norm.dot(x0_data[0])};
|
||||
}
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "Runtime/GCNTypes.hpp"
|
||||
|
||||
#include <zeus/CPlane.hpp>
|
||||
|
@ -7,17 +9,15 @@
|
|||
|
||||
namespace urde {
|
||||
class CCollisionSurface {
|
||||
zeus::CVector3f x0_a;
|
||||
zeus::CVector3f xc_b;
|
||||
zeus::CVector3f x18_c;
|
||||
std::array<zeus::CVector3f, 3> x0_data;
|
||||
u32 x24_flags;
|
||||
|
||||
public:
|
||||
CCollisionSurface(const zeus::CVector3f&, const zeus::CVector3f&, const zeus::CVector3f&, u32);
|
||||
CCollisionSurface(const zeus::CVector3f& a, const zeus::CVector3f& b, const zeus::CVector3f& c, u32 flags);
|
||||
|
||||
zeus::CVector3f GetNormal() const;
|
||||
const zeus::CVector3f& GetVert(s32 idx) const { return (&x0_a)[idx]; }
|
||||
const zeus::CVector3f* GetVerts() const { return &x0_a; }
|
||||
const zeus::CVector3f& GetVert(s32 idx) const { return x0_data[idx]; }
|
||||
const zeus::CVector3f* GetVerts() const { return x0_data.data(); }
|
||||
zeus::CPlane GetPlane() const;
|
||||
u32 GetSurfaceFlags() const { return x24_flags; }
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue