2019-09-28 02:53:03 +00:00
|
|
|
#include "Runtime/Collision/CCollisionSurface.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CUnitVector.hpp>
|
2016-06-24 20:09:38 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2018-12-08 05:30:43 +00:00
|
|
|
CCollisionSurface::CCollisionSurface(const zeus::CVector3f& a, const zeus::CVector3f& b, const zeus::CVector3f& c,
|
|
|
|
u32 flags)
|
2020-04-06 09:54:21 +00:00
|
|
|
: x0_data{a, b, c}, x24_flags(flags) {}
|
2016-12-26 07:58:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CVector3f CCollisionSurface::GetNormal() const {
|
2020-04-06 09:54:21 +00:00
|
|
|
const zeus::CVector3f v1 = (x0_data[1] - x0_data[0]).cross(x0_data[2] - x0_data[0]);
|
2018-12-08 05:30:43 +00:00
|
|
|
return zeus::CUnitVector3f(v1, true);
|
2016-12-26 07:58:44 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CPlane CCollisionSurface::GetPlane() const {
|
2020-04-06 09:54:21 +00:00
|
|
|
const zeus::CVector3f norm = GetNormal();
|
|
|
|
return {norm, norm.dot(x0_data[0])};
|
2016-12-26 07:58:44 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|