diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2021-12-04 05:29:00 -0800 |
|---|---|---|
| committer | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2021-12-04 05:29:00 -0800 |
| commit | b88340aca702199c077a91d75eea20550732891f (patch) | |
| tree | f90646d85adb5e2642e93c12f48fa7156d4bc09a /include/SSystem/SComponent | |
| parent | fd9c4cafc4d9aa3df4b2f43ee33f15152482fce9 (diff) | |
| parent | f6f7e7ce38a9af6ca605261a5d2485a6edc6b733 (diff) | |
merge
Diffstat (limited to 'include/SSystem/SComponent')
| -rw-r--r-- | include/SSystem/SComponent/c_lib.h | 5 | ||||
| -rw-r--r-- | include/SSystem/SComponent/c_xyz.h | 11 |
2 files changed, 12 insertions, 4 deletions
diff --git a/include/SSystem/SComponent/c_lib.h b/include/SSystem/SComponent/c_lib.h index ca3406b0e0..7a19786430 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-11f; +} 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 f7a57a7b6a..1ecc679a0e 100644 --- a/include/SSystem/SComponent/c_xyz.h +++ b/include/SSystem/SComponent/c_xyz.h @@ -4,6 +4,7 @@ #include "dolphin/mtx/vec.h" #include "msl_c/math.h" #include "global.h" +#include "msl_c/math.h" struct cXyz : Vec { static const cXyz Zero; @@ -51,11 +52,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; @@ -117,10 +120,10 @@ struct cXyz : Vec { cXyz tmp2(other.x, 0, other.z); return tmp.abs2(tmp2); } - f32 absXZ(const Vec& other) const { - f32 abs = abs2XZ(other); - return sqrtf(abs); - } + f32 abs() const { return sqrtf(this->abs2()); } + f32 abs(const Vec& other) const { return sqrtf(this->abs2(other)); } + f32 absXZ() const { return sqrtf(this->abs2XZ()); } + f32 absXZ(const Vec& other) const { return sqrtf(this->abs2XZ(other)); } f32 getMagXZ() const { return cXyz(this->x, 0, this->z).getSquareMag(); } }; |
