From 58715df2cbe3555f4de0d3bcc6a8a8ede1239fc8 Mon Sep 17 00:00:00 2001 From: lepelog <25211966+lepelog@users.noreply.github.com> Date: Tue, 9 Nov 2021 21:09:33 +0100 Subject: cLib_addCalcPos --- include/SSystem/SComponent/c_lib.h | 5 +++++ include/SSystem/SComponent/c_xyz.h | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'include') diff --git a/include/SSystem/SComponent/c_lib.h b/include/SSystem/SComponent/c_lib.h index 8ff0092bc1..cdbfb6356e 100644 --- a/include/SSystem/SComponent/c_lib.h +++ b/include/SSystem/SComponent/c_lib.h @@ -4,6 +4,11 @@ #include "SSystem/SComponent/c_xyz.h" #include "dolphin/mtx/mtx.h" #include "dolphin/types.h" +#include "msl_c/math.h" + +inline bool cLib_IsZero(f32 f) { + return fabsf(f) < 8e-11; +} void cLib_memCpy(void* dst, const void* src, unsigned long size); void cLib_memSet(void* ptr, int value, unsigned long size); diff --git a/include/SSystem/SComponent/c_xyz.h b/include/SSystem/SComponent/c_xyz.h index 0f28e22048..5cef049e7f 100644 --- a/include/SSystem/SComponent/c_xyz.h +++ b/include/SSystem/SComponent/c_xyz.h @@ -3,6 +3,7 @@ #include "dolphin/mtx/vec.h" #include "global.h" +#include "msl_c/math.h" struct cXyz : Vec { static const cXyz Zero; @@ -50,11 +51,13 @@ struct cXyz : Vec { y -= f; z -= f; } + void operator-=(const Vec& other) { PSVECSubtract(this, &other, this); } void operator+=(const Vec& vec) { x += vec.x; y += vec.y; z += vec.z; } + void operator*=(f32 scale) { PSVECScale(this, this, scale); } /* 80266C6C */ cXyz getCrossProduct(Vec const&) const; /* 80266CBC */ cXyz outprod(Vec const&) const; /* 80266CE4 */ cXyz norm() const; @@ -116,6 +119,8 @@ struct cXyz : Vec { cXyz tmp2(other.x, 0, other.z); return tmp.abs2(tmp2); } + f32 abs() const { return sqrtf(this->abs2()); } + f32 abs(const Vec& other) const { return sqrtf(this->abs2(other)); } f32 getMagXZ() const { return cXyz(this->x, 0, this->z).getSquareMag(); } }; -- cgit v1.2.3